O'Reilly logo

Developing Mobile Games with Moai SDK by Francisco Tufro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exercises

Adding enemies to this scene should be familiar to you by now. You'll need to think about the artificial intelligence for the movement, but other than that, everything else has have already been seen. You should create it as a dynamic body, and modify the player collision handler in order to react properly (killing the player for example, or taking life from it).

Another great idea would be to implement Mario-style platforms where you can jump up through the bottom of a platform and then collide and stay on top. (You'll have to use Box2D's sensors and check the normal of collision in the collision handler. Then, based on the collision normal, only stop movement at the appropriate time).

Play around a bit with this, since playing is a big ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required