Hi all,
I have a problem with inheritance. I want to do a Class Player, and this has a atributes like Name,Description,Force,Velocity,…
I read the tutorial for JME the flagrush, and when He creates a Vehicle, he were doing:
Public Class Vehicle Extends Node
And when I do the player, I want to extends of DynamicPhysicsNode, that is a abstract class… I do the class "Player" abstract and extends DynamicPhysicsNode, but how I can createDynamicNode(). how I can inicialized the Player?
There are another way to create a class Player?
Thanks for all!
and sorry for my bad English… ://
Make a class Player, which has a DynimicNode.
Dynamic and static nodes are created by the physicsspace so in this particular case you cannot extend your player with it and inject the Node in it. I would extend from node, create the dynamic node in the constructor attach every dynamic-related object to it. then just attach it to your player class. and now you can attach your player-class as wanted to the scenegraph. something like this(not tested):
class Player extends Node
{
private float health;
private DynamicPhysicsNode d;
pubic Player()
{
this.health=10.0f;
d = getPhysicsSpace().createDynamicNode();
d.attachChild(…box…)
attachChild(d);
}
}