O'Reilly logo

Irrlicht 1.7 Realtime 3D Engine by Aung Sithu Kyaw, Johannes Stein

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

Time for action - using a sprite sheet

Let's get this little robot guy animated. The best way is to use the example of our last exercise:

  1. Copy the robot sprite sheet to your application folder.
  2. Change ../../media/irrlichtlogo2.png in ITexture* image = driver->getTexture("../../media/irrlichtlogo2.png"); to robot.png.
  3. After that line add driver->makeColorKeyTexture(image, position2d<s32>(0, 0));.
  4. Add a variable called currentFrame having the int type and initialize this variable with 0.
  5. Add another int variable called row initialized with 0.
  6. Directly in the "game loop" even before the beginScene() method add the following piece of code:
    u32 time = device->getTimer()->getTime(); if ((time % 25) == 0) currentFrame++; if (currentFrame >= 31) { currentFrame ...

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