Motorola C550, C450, C370 technical manual Using PlayField

Page 54

public void setViewWindow(int x, int y, int width, int height) – Sets the portion of the PlayField that will be drawn when draw(Graphics, int, int) is called. This will limit the portion of the PlayField that is drawn to the rectangle defined by the region (x, y) to (x + width, y + height). The default view window (at construction time) is the entire area of the PlayField, i.e. the rectangular region bounded by (0, 0) and (getGridWidth() * getCellWidth(), getGridHeight() * getCellHeight()).The rectangle defined by the parameters may extend beyond the bounds of the PlayField. If this happens, the draw(graphics, int, int) method will draw no tiles in the area outside the grid boundaries. Sprites may still be drawn in this area if their position places them outside the bounds of the PlayField grid. The view window stays in effect until it is modified by another call to this method or is reset as a result of calling setStaticTileSet(Image, int, int). The method parameters are x - x coord of top-left pixel for the drawing view window, y - y coord of top-left pixel for the drawing view window, width - width of the drawing view window, and height - height of the drawing view window.

Using PlayField

The following is a code sample to show implementation of PlayField:

PlayField

//Creates a playField with 100 columns and 10

//rows and tiles with 24x16 pixels

PlayField foreground = new PlayField(100, 10,

Image.createImage("tiles.png"), 24, 16);

//Sets the first cell in the first line to

//empty(tile with index 0) foreground.setCell(0, 0, 0);

//Fills the second cell in the first line with tile 1 foreground.setCell(1, 0, 1);

//Fills the third cell in the first line with tile 2 foreground.setCell(2, 0, 2);

//Fills the fourth cell in the first line with tile 3 foreground.setCell(3, 0, 3);

//Gets the Graphics object for this GameScreen Graphics g = getGraphics();

//Draws the foreground playfield

foreground.draw(g, 0, 0);

Image 54
Contents Technical Manual Table of Contents Lcdui JAD Attributes Audience IntroductionPurpose DisclaimerReferences Date Name Reason Revision HistoryDefinitions, Abbreviations, Acronyms Acronym DescriptionDocument Overview Introduction J2ME Introduction Java 2 Platform, Micro Edition J2MEMotorola J2ME Platform Resources AvailableFile & RMS Description DisplayNetworking 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 BackgroundMusic Methods Using BackgroundMusicBackgroundMusic Class 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 PlayFieldSprite Class Using SoundEffectSoundEffect Class SoundEffect MethodsAnimation Frames Sprite DrawingSprite Constructor Sprite Methods Page Public final void drawGraphics g throws Using Sprite FileFormatNotSupportedExceptionSprites FileFormatNotSupportedException Constructors Java Gaming Sound APIMax Midi Extension Support 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 Code Examples Record Management SystemClass Description 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