📄 startfinish.java
字号:
/*
* Copyright 2003, 2004 Symbian Ltd.
* For License terms see http://www.symbian.com/developer/techlib/codelicense.html
*/
package demoracer;
/**
* <p>Title: DemoRacer</p>
* <p>Description: Game API Demo for Symbian MIDP 2.0 Book.</p>
* @author Alan Newman - alan@sensibledevelopment.net
* @version 1.0
*/
/*
* This is a rather simple Sprite class which forms the StartFinish line graphic.
* This has been separated from the tiled background to allow for collision detection.
*/
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
public class StartFinish extends Sprite {
// set the frame set dimensions
static final int FRAME_COLS=1;
static final int FRAME_WIDTH=1;
private int xInitial;
private int yInitial;
private int frequency;
private boolean lapComplete=false;
public StartFinish(Image image, int width, int height, int x, int y) {
super(image,width,height);
this.setPosition(x,y);
xInitial=x;
yInitial=y;
frequency = 4*Background.TILE_WIDTH;
}
public boolean getLapComplete(){return lapComplete;}
public void setLapComplete(boolean bln){lapComplete=bln;}
// move the start finish line from right to left along with the tiled background.
public void tick() {
if (frequency == 0) {
setPosition(xInitial, yInitial);
frequency = 4*Background.TILE_WIDTH;
} else{
move(Background.xMove, Background.yMove);
}
// set to invisible if the sprite is off screen.
if(getX() + getWidth() <= 0) {//definitely outside Canvas clip area
setVisible(false);
} else {
setVisible(true);
}
frequency--;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -