Motorola C370, C550, C450 technical manual Animation Frames, Sprite Drawing, Sprite Constructor

Page 56

Animation Frames

An animated sprite is created from an image divided into sections as described in the constructor Sprite(Image, int, int). The individual sections of the image are considered the raw frames of the Sprite. The method getNumRawFrames returns the number of raw frames.

Sprite Drawing

Sprites can be drawn at anytime using the draw(Graphics) method. The sprite will be drawn on the Graphics object, according to the current state information maintained by the Sprite (i.e. position, frame, visibility). Some potential uses of Sprites include:

Arbitrarily draw the Sprite on a GameScreen.

A Sprite can be added to a PlayField. Then PlayField.draw(Graphics, int, int) will automatically draw all the Sprites associated with the PlayField.

draw(Graphics) could be called from the paint() method in a subclass of

Canvas.

draw(Graphics) could be called at any time to draw the Sprite on a MIDP mutable image. This is virtually identical to the first bullet, drawing on a GameScreen.

Only in the case where a set of Sprites are a part of a container object (i.e. where the Sprite is associated with a PlayField) is the depth information automatically handled by the system. In other situations, managing the drawing order is the responsibility of the developer.

Sprite Constructor

The Sprite class defines the following constructors:

public Sprite(Image img) – Creates a new non-animated Sprite from an Image object. All animation operations on a non-animated Sprite behave as if there is a single raw frame. At construction time, the Sprite's position will be set to (0,0), the depth will be set to 0, and the Sprite will be visible. The Sprite shall behave as if the image used in creation were cached. If a mutable image is used to create the Sprite, the Sprite's appearance should not reflect changes to mutable source image.

public Sprite(Image img, int fWidth, int fHeight)

Creates a new animated Sprite from an Image. The constructor parameters are the following:

img - Image to use for Sprite;

fWidth - width, in pixels, of the individual raw frames;

fHeight - height, in pixels, of the individual raw frames.

Image 56
Contents Technical Manual Table of Contents Lcdui JAD Attributes Introduction PurposeAudience DisclaimerReferences Revision History Definitions, Abbreviations, AcronymsDate Name Reason Acronym DescriptionDocument Overview Introduction J2ME Introduction Java 2 Platform, Micro Edition J2MEMotorola J2ME Platform Resources AvailableDescription Display NetworkingFile & RMS Java VMIntroduction to Development Developing and Packaging J2ME ApplicationsGuide to Development in J2ME Page Downloading Applications OTA ProcedureInstallation Program and Data space notes Exiting Applications Java Application Installer/De-Installer JaidStarting Applications Downloading MIDlets Error ChecksLaunching Web Session for Http Download XML Screen Renderings BombMan is back, now on your Taichi series of handsets Taichi handset New Games Application Management MIDlet LifecycleMIDlet Suite Installation MIDlet Suite De-installation MIDlet Suite Updating DestroyAppMethod Caller PurposeStartApp or the pauseApp Using startApp Java System MIDlet Control of MIDlet State TransitionsPage Network API Network ConnectionsClass Descriptions IOException when it detects a time-out condition URL FormatImplementation Notes TCP SocketsUDP Sockets Network API Lcdui DescriptionLcdui Class Hierarchy Gaming API and SoundFunctional Description Using BackgroundMusic BackgroundMusic ClassBackgroundMusic Methods Gaming API containing a sound APIGameScreen Class GameScreen FieldsGameScreen Methods Public int getKeyStatesInformation, disabling key events can improve performance Using GameScreen GameScreenImageUtil Methods ImageUtil ClassImageUtil Fields Using ImageUtil RgbDataPalleteImage Methods PalleteImage ClassPalleteImage Constructor Using PalleteImage Public void setTransparentIndexint index throwsUsing Static and Animated Tiles PlayField ClassPlayField Constructor Using SpritesDefining View Windows 2N+1 2N + PlayField Methods Public void addSpriteSprite s throwsPage Public boolean collidesWithAnyTileSprite s throws Using PlayField PlayFieldUsing SoundEffect SoundEffect ClassSprite Class SoundEffect MethodsSprite Constructor Animation FramesSprite Drawing Sprite Methods Page Public final void drawGraphics g throws Sprites Using SpriteFileFormatNotSupportedException Java Gaming Sound API Max Midi Extension SupportFileFormatNotSupportedException Constructors Java Gaming Sound APIVibe and Backlight Vibe and Backlight APIOverview Creating a MessageSending a Message PermissionsJAD Attributes JAD AttributesMandatory attributes for manifest files MIDlet-Name Record Management System Class DescriptionCode Examples RecordStoreTips CaveatsPhonebook Access Phonebook Access APIPhonebook Access API Permissions Sample of code to create object of PhoneBookRecord classSimmemory Sample of code for calling of ‘getMaxEmailLength ’ method Sample of code for calling of ‘isPrimaryint speedNo’ method Sample of code for calling of ‘getNumberCategories’ method Sample of code for calling of ‘setCategoryView’ method Sample of code for calling of ‘getUsedRecords’ method Int index = ReceivedRecord.getRecord1 ITAP Intelligent Keypad Text Entry APIAppendix a Key Mapping Key Mapping for the C370, C450, and C550Center Select END Appendix B Memory Management Calculation Available MemoryOnline FAQ Appendix CAppendix D Spec Sheets C370, C450, and C550 Spec SheetsReferences Purchase Motorola Developer Information ToolsDocumentation Motorola Developer Information Tools Motorola, Inc
Related manuals
Manual 110 pages 1.04 Kb