⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 中文.txt

📁 手机蓝牙驱动和应用实例源码
💻 TXT
字号:
GameMIDlet.java			Entry point of the game
GMCanvas.java			This is where most of the work is done. Contains the main game loop etc
SplashScreen.java		Displays a splash screen
Dictionary.java			This loads the en.txt file and assigns values to each line in the text file
GameEffects.java		Handles sound, including loading the music / effects. More on this later
Standard.java			Handles functions such as displaying text in boxes, saving to RMS etc.
BGLayer.java			Handles multi directional scrolling.
BlueTooth.java			An almost empty file for now. We'll deal with this later.
MCanvas(GameMIDlet)
构造器- not doing a great deal here, just ensuring the gameMode is set and key events are allowed.

keyReleased(int keyCode)
keyPressed(int keyCode)
I decided not to use getKeyStates() and made my own. This is because I found some issues with using getKeyStates and keyReleased() & keyPressed() methods.
Softkeys are used to navigate some portions of the menu and pause the game. This is dealt with in keyPressed().
My keyStates variable gets updated in these two methods.

changePause()
Used when a manual attempt to pause the game is made. ie via softkeys.

init()
I use this to load the bulk of the graphics. At the moment it just loads the menu icons.

start()
stop()
Deal with issues for starting and stopping the thread for this runnable.

run()
The main game loop I guess. Starts off by initializing some counters for the frame timer then starts the while loop.
First do some bluetooth stuff to retrieve any sent data, but we can ignore this for now.
Then call tick(), draw() and then flushGraphics().
Also calculates the framerate and does its best to ensure the game runs at a set framerate.

tick()
This is a state driven game framework and nothing shows this more than the tick() method with the game state being held in a variable called gameMode.
Have a quick look at this method, we'll go into it in more depth later.

updateMenu(boolean up, boolean down, boolean fire)
Handles game menu navigation and what to do when you select an option. Basically you pass in the input from the user and the action is performed here.
I must admit this isnt the best piece of code i've ever written but it does the job and chances are you'll want to write your own menu code anyway.
I'll explain this a little as it looks quite confusing at first.
Variables used are:
optionPage	- holds the menu option page you are on
option		- holds the option you are on within that option page
MAX_OPTIONS[]	- holds the number of options for each page
options[]	- holds whether or not an option is available - i've tied this in with the optionPage variable so it can look untidy at times.

playInput(int p, int d)
This is going to handle the players input and process his key presses. Not much here yet though!

btAbort()
More bluetooth stuff to handle abort and disconnect from a bluetooth game.

sendBlueTooth()
getKeys(boolean bSend)
Sets some key pressed variable based on my keyStates variable. Also makes a call to send this info if the game is 2 player.

drawTitle(Graphics g)
drawCredit(Graphics g)
drawMenu(Graphics g)
drawSoftKey(Graphics g, int l, int r)
draw()
You dont need to be Eintien to guess that these methods draw something on the screen. draw() is the main method and again is state driven.
Towards the end of this method the frame rate is displayed.

storeGame()
Performs some game state checks to see if we need to store the game info in the RMS.

setPosition()
collTest()
restartLevel(int lvl)
I'll go into these later when we introduce more elements to the framework.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -