Motorola C450, C550, C370 Using Sprites, Defining View Windows, PlayField Constructor

Page 49

8

Gaming API and Sound

calling setAnimatedTileImage(-2, 2);, cells (0,0) and (0,1) will then be drawn with the image of static Tile 2.

Using Sprites

In addition to being a grid of cells, a Playfield can have a set of associated Sprites (see 0 item). When the PlayField is drawn, the grid is considered to have depth 0. Therefore, Sprites below the grid (Sprites with Sprite.getDepth() < 0) are drawn first. Then all cells in the grid are drawn. Then all the Sprites above the grid (Sprite.getDepth() >= 0) are drawn. The Sprites are drawn according to their location and visibility status as defined in the Sprite class. The location of Sprites is relative to the top-left corner of the PlayField.

Defining View Windows

A view window onto the PlayField can be defined using the method setViewWindow(). This defines the area of the PlayField that will be drawn by the draw() method. The default viewing window onto a PlayField (at construction time) is the entire area of the PlayField.

PlayField Constructor

The PlayField class defines the following constructors:

PlayField (int columns, int rows, Image img, int tWidth, int tHeight) throws NullPointerException, IllegalArgumentException - Creates a new PlayField with a tile set. The parameter are the following:

columns - width of the PlayField in number of cells;

rows - height of the PlayField in number of cells;

img - Image to use for creating tiles;

tWidth - width, in pixels, of the individual tiles;

tHeight - height, in pixels, of the individual tiles.

It creates a new PlayField, rows cells high and columns cells wide. The static tile set for the PlayField will be created from subsections of the image passed in. The PlayField grid is initially filled with empty cells (tile 0 - a reserved tile and represents an empty square) and laying out tiles must be accomplished through the use of other methods in the class. The creation of the static tile set follows these standards:

Tiles must be equally sized, all being of the tile width (tWidth) and height

(tHeight) defined in the constructor parameters. They may be laid out in the image horizontally, vertically, or as a grid. The width of the source image must be an integer

49

Image 49
Contents Technical Manual Table of Contents Lcdui JAD Attributes Purpose IntroductionAudience DisclaimerReferences Definitions, Abbreviations, Acronyms Revision HistoryDate Name Reason Acronym DescriptionDocument Overview Introduction Java 2 Platform, Micro Edition J2ME J2ME IntroductionResources Available Motorola J2ME PlatformNetworking Description DisplayFile & RMS Java VMGuide to Development in J2ME Developing and Packaging J2ME ApplicationsIntroduction to Development Page Installation OTA ProcedureDownloading Applications Program and Data space notes Starting Applications Java Application Installer/De-Installer JaidExiting Applications Launching Web Session for Http Download Error ChecksDownloading MIDlets XML Screen Renderings BombMan is back, now on your Taichi series of handsets Taichi handset New Games MIDlet Lifecycle Application ManagementMIDlet Suite Installation MIDlet Suite De-installation DestroyApp MIDlet Suite UpdatingCaller Purpose MethodStartApp or the pauseApp Using startApp MIDlet Control of MIDlet State Transitions Java SystemPage Network Connections Network APIClass Descriptions URL Format IOException when it detects a time-out conditionUDP Sockets TCP SocketsImplementation Notes Network API Description LcduiLcdui Functional Description Gaming API and SoundClass Hierarchy BackgroundMusic Class Using BackgroundMusicBackgroundMusic Methods Gaming API containing a sound APIGameScreen Fields GameScreen ClassPublic int getKeyStates GameScreen MethodsInformation, disabling key events can improve performance GameScreen Using GameScreenImageUtil Fields ImageUtil ClassImageUtil Methods RgbData Using ImageUtilPalleteImage Constructor PalleteImage ClassPalleteImage Methods Public void setTransparentIndexint index throws Using PalleteImagePlayField Class Using Static and Animated TilesDefining View Windows Using SpritesPlayField Constructor 2N+1 2N + Public void addSpriteSprite s throws PlayField MethodsPage Public boolean collidesWithAnyTileSprite s throws PlayField Using PlayFieldSoundEffect Class Using SoundEffectSprite Class SoundEffect MethodsSprite Drawing Animation FramesSprite Constructor Sprite Methods Page Public final void drawGraphics g throws FileFormatNotSupportedException Using SpriteSprites Max Midi Extension Support Java Gaming Sound APIFileFormatNotSupportedException Constructors Java Gaming Sound APIVibe and Backlight API Vibe and BacklightCreating a Message OverviewPermissions Sending a MessageJAD Attributes JAD AttributesMandatory attributes for manifest files MIDlet-Name Class Description Record Management SystemCode Examples RecordStoreCaveats TipsPhonebook Access API Phonebook AccessSample of code to create object of PhoneBookRecord class Phonebook Access API PermissionsSimmemory 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 Intelligent Keypad Text Entry API ITAPKey Mapping for the C370, C450, and C550 Appendix a Key MappingCenter Select END Available Memory Appendix B Memory Management CalculationAppendix C Online FAQC370, C450, and C550 Spec Sheets Appendix D Spec SheetsDocumentation Motorola Developer Information ToolsReferences Purchase Motorola Developer Information Tools Motorola, Inc
Related manuals
Manual 110 pages 1.04 Kb