Still having probs with my collision detection. Very nearly got it but had soe glitches, back to square one.
Have surrounded my mario sprite (Quad) with a bounding box (see image)… When I move left the collision detection with the wall works a treat. However this doesnt prevent me from stopping before I hit the wall (ie mario stops after I have collided with the wall)…
What I would like to do is move the bounding box before doing my collision detection. Is this possible
// i.e.I would like to move my BoundingBox here, if possible.. Any ideas?
You should see if there's a collision before anything is drawn, and then change the position back to something that does not collide (eg the last time you tested for collisions and there were none, but much better is something calculated based on your knowledge of the scene or the object you hit).
Thanks for you support llama, appreciated… First games are always a bit tough.
Yep, the xExtent stuff altered the size of my bounding box, will try and understand this better 2moro to see if it solves problem. (2am now, bedtime…)…
Sorry, another noob question… I assume from your response that you can control when things are drawn… Can you point me in the right direction as to how… I noticed that
when I perform my myQuad.setLocalTranslation(…) method (in SimpleUpdate) this is drawn immediately… How can I control when this is drawn?
There's commenly (for example in SimpleGame) two phases, the "update" phase, and the "render" phase. In update, input is processed, objects local parameters (translation, scale and rotation) are moved around based on that input and other factors (controllers for example), and then finally the actual "world" parameters (based on the local ones, these tell the engine where and how objects should be drawn) are calculated. This includes that of the bounds as well!
Once this is done, in SimpleGame simpleUpdate is invoked. Since the scene has changed you now do another round of collision detection… however any changes you make to the object local parameters are not used till the next "update" phase. Unless you manually do this with updateWorldData/updateGeometricState… however if you have controllers and such these should be only be called once per frame. Thankfully there is updateWorldVectors which is safe to use, however only updates geometries (not Nodes). Might be enough for your Mario though.
The next phase is the render phase where all the object are draw by the videocard. Then simpleRender is invoked.
SimpleGame limits you to this model… because it is supposed to be simple. Once you make a more complex game however… you'll find out without SimpleGame you can do much more complicated things. All jME geometries and Nodes have their own update and draw methods, and you can invoke them when you want, and seperatly too, or several times. If you look inside Simple(Base)Game you can see how some of these methods are invoked.