📄 ufocanvas.java
字号:
package src;import javax.microedition.lcdui.*;import javax.microedition.lcdui.game.*;import java.util.*;import java.io.*;public class UFOCanvas extends GameCanvas implements Runnable { private Display display; private boolean sleeping; private long frameDelay; private Random rand; private Sprite ufoSprite; private int ufoXSpeed, ufoYSpeed; private Sprite[] roidSprite = new Sprite[5];//绮剧伒鏁扮粍 private long gametime; private long gametimeoffset; /**娓告垙鏆傚仠鍙橀噺*/ public boolean isPaused = false; String pauseStr = "鏆傚仠"; String continueStr = "缁х画"; /**娓告垙缁撴潫鍙橀噺*/ boolean gameOver = false; int width; int height; public UFOCanvas(Display d) { super(false); width = getWidth(); height = getHeight(); display = d; gametime = 0; // Set the frame rate (30 fps) frameDelay = 33; } public void start() { // Set the canvas as the current screen display.setCurrent(this); // Initialize the random number generator rand = new Random(); this.gametimeoffset = System.currentTimeMillis(); // Initialize the UFO and roids sprites ufoXSpeed = ufoYSpeed = 0; try { ufoSprite = new Sprite(Image.createImage("/Saucer.png")); ufoSprite.setPosition((getWidth() - ufoSprite.getWidth()) / 2, (getHeight() - ufoSprite.getHeight()) / 2);//鍒濆
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -