Motorola C550, C450, C370 technical manual FileFormatNotSupportedException, Using Sprite, Sprites

Models: C450 C550 C370

1 86
Download 86 pages 61.66 Kb
Page 60
Image 60

Any custom frame sequence will be deleted and the frame sequence will revert to the default frame sequence for the new frame set (all frames in the frame set, left-to-right then top-to-bottom).

Using Sprite

The example below creates two Sprites (bullet and tank) and tests collisions between them. When there are no lives left, the game finishes.

The following is a code sample to show implementation of using sprites:

Sprites

try {

Sprite bullet = new Sprite(Image.createImage("bullet.png"); Sprite tank = new Sprite(Image.createImage("tank.png");

} catch (Exception e) {

//any image can't be loaded

}

Boolean isGameOver= False;

int lifes= 3; // The number of lives is 3 while(!isGameOver) {

//verifies the collision between the two sprites if(tank.collidesWith(bullet,false)) {

lifes--;

//If there are no more lifes, the game is over if(lifes == -1) {

isGameOver = true;

}

}

}

FileFormatNotSupportedException

The FileFormatNotSupportedException is an exception which will be thrown when a SoundEffect or BackgroundMusic format is not supported by the platform or the size of the data is larger than the size of the internal buffers. The

FileFormatNotSupportedException extends the java.lang.RuntimeException class.

Page 60
Image 60
Motorola C550, C450, C370 technical manual FileFormatNotSupportedException, Using Sprite, Sprites