"Java MobilePDA Program Design" Reading Note 10 - Game API

xiaoxiao2021-03-06  19

Game API consists of 5 classes GAMECANVAS - LAYERMANAGER - LayerspritileDlayer

Gamecanvas inherits Canvas with all the features of Canvas. And GameCanvas provides GetKeyStates (), detects the case where the button is pressed. Gamecanvas also provides flushgraphics (), which displays off-screen content to the screen, does not produce an over-draw event.

LayerManager provides features that manage multiple layers, which makes it easy to mix the foreground and background on the same screen and output to the screen. LayerManager can have many Layer subclasses, standard MIDP provides Sprite and Tiledlayer's subclasses of two Layer.

Every time Gamecanvas generates a GameCanvas subclass, it will automatically generate a size equivalent full screen OFF-Screen constructor public mygamecavas () {super (true); whether to suppress keyboard events (including keypressed () / keyreleased () / keyrepeated ()) TRUE represents to suppress. }

GetKeyStates () Before calling getKeyStates (), the button was previously pressed, then the corresponding position in the buffer will be set 1, otherwise it is set to 0. This will not allow the program to miss the button that the user has pressed. After getKeyStates (), the contents of the keyboard status buffer will be cleared. After removing the keyboard state, the positioning calculation can know whether a button is pressed: (! (Keystate & UP_PRESSED) = 0) if {......} GameCanvas state are defined: UP_PRESSED DWON_PRESSED LEFT_PRESSED RIGHT_PRESSEDFIRE_PRESSED GAME_A_PRESSED GAME_B_PRESSED GAME_C_PRESSED GAME_D_PRESSED

LayerManager and Layersprite are to join the LayerManager with the LayerManager's APPEND to unify these Layer. The index value of the Layer starts at 0. The smaller the value, the closer to the user, the sooner added. When Layer is already in LayerManager, Layer will be deleted first, then join. Remove () and INSERT can be removed from the LayerManager at any time, inserting a Layer.

getLayer () gets the Layergetsize () of an index value, how many of the number of LayerManager have the size of the LayerManager setting the size of the View Window.

The Sprite screen is independently moving graphics Sprite class to create a Row Frame array based on the read image, and another Frame Sequence array content is the index value of the picture. Current Frame refers to a screen displayed on the current screen.

getRawFrameCount () to obtain the number of Raw Frame of getFrameSequence () to obtain the number of getFrame Frame Sequence () Gets the current point to Current Frame Frame Sequence array which elements setFrame () set the contents of an element nextFrame Frame Sequence () / prevFrame () lets Current Frame points to the next or last element of the framesequence array

转载请注明原文地址:https://www.9cbs.com/read-41148.html

New Post(0)