Motorola C550, C450, C370 technical manual PlayField Class, Using Static and Animated Tiles

Page 48

raceCar.setPaletteEntry(0, 0x0000FF); Image blueRaceCar = raceCar.getImage();

//Set the car color to green and retrieve the Image raceCar.setPaletteEntry(0, 0x00FF00);

Image greenRaceCar = raceCar.getImage();

//The PaletteImage can now be discarded since we have the

//Image objects that we need

raceCar = null;

PlayField Class

APlayField is a rectangular grid of cells with a set of available tiles to place in those cells and a set of associated Sprites.

The PlayField grid is made up of (rows * columns) cells, where the number of rows and columns are defined by parameters to the constructor. The cells are equally sized. The size of the cells is defined by the size of the tiles, or if the PlayField has no tiles, by arguments to the constructor. Each cell is either empty or contains a single tile whose image will be drawn in that cell. An empty cell is fully transparent - Nothing will be drawn in that area by the PlayField.

The tiles used to fill the PlayField cells can be either static tiles or animated tiles. Tiles are referred to using index numbers. Tile 0 (tile with index 0) refers to the special empty tile. Any cell assigned the tile 0 will be considered empty and will be effectively transparent.

The static tile indices are non-negative (>=0) and the animated tiles indices are negative (<0).

Using Static and Animated Tiles

Static tiles are called static because their image does not often change, i.e., any cell that contains the static Tile 1 will always be drawn as the unchanging image of Tile 1. Tile 0 is a special static tile. It represents an empty cell. Any cell containing tile 0 will be transparent, it will not have a tile image drawn in it.

Animated tiles are called animated because their appearance changes easily over time. At any given time, each animated tile is associated with a particular static tile. When a cell containing an animated tile is drawn, the image of the static tile currently referenced by that animated tile will be drawn in that cell. In effect, the animated tiles provide indirect references to the set of static tiles, and therefore allow many cells to be animated simultaneously. For example, cells (0,0) and (0,1) both contain animated Tile -2. Animated Tile -2 currently references static Tile 1. Cells (0,0) and (0,1) will then be drawn with the image of static Tile 1. If animated Tile -2 is subsequently set to reference static Tile 2 by

Image 48
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 VMDeveloping and Packaging J2ME Applications Guide to Development in J2MEIntroduction to Development Page OTA Procedure InstallationDownloading Applications Program and Data space notes Java Application Installer/De-Installer Jaid Starting ApplicationsExiting Applications Error Checks Launching Web Session for Http DownloadDownloading MIDlets 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 FormatTCP Sockets UDP SocketsImplementation Notes Network API Lcdui DescriptionLcdui Gaming API and Sound Functional DescriptionClass Hierarchy 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 Class ImageUtil FieldsImageUtil Methods Using ImageUtil RgbDataPalleteImage Class PalleteImage ConstructorPalleteImage Methods Using PalleteImage Public void setTransparentIndexint index throwsUsing Static and Animated Tiles PlayField ClassUsing Sprites Defining View WindowsPlayField Constructor 2N+1 2N + PlayField Methods Public void addSpriteSprite s throwsPage Public boolean collidesWithAnyTileSprite s throws Using PlayField PlayFieldUsing SoundEffect SoundEffect ClassSprite Class SoundEffect MethodsAnimation Frames Sprite DrawingSprite Constructor Sprite Methods Page Public final void drawGraphics g throws Using Sprite FileFormatNotSupportedExceptionSprites 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 SheetsMotorola Developer Information Tools DocumentationReferences Purchase Motorola Developer Information Tools Motorola, Inc
Related manuals
Manual 110 pages 1.04 Kb