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

📄 startfinish.java

📁 Programming java 2 microedition symbian os一书中作者编写的一个赛车游戏的半成品
💻 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 + -