peopleclass.java

来自「netbean下开发的」· Java 代码 · 共 73 行

JAVA
73
字号
/*
 * PeopleClass.java
 *
 * Created on 2007年6月3日, 下午10:14
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package hello;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import java.io.IOException;
import javax.microedition.lcdui.game.Sprite;
/**
 *
 * @author FXB
 */
public class PeopleClass {
    private Sprite People;
    private int Speed;
   
    private float peak;//peak为人上升和下降的加速度
    
    private float peaklength;        //初时的两帧的间距
    
    private float peopleY;
    
    private float prepeopleY;
    
    private float nextpeopleY;
    //private int X;
    //private int Y;
    
    /** Creates a new instance of PeopleClass */
    public PeopleClass(Sprite People,int Speed) {
        //peak为人上升和下降的加速度
        this.peak = 0.3f;
        //初时的两帧的间距
        this.peaklength = peaklength;
        
        this.People = People;
        //人的移动速度
        this.Speed = Speed;
        
        this.peopleY = this.People.getRefPixelY();
        this.prepeopleY = this.peopleY;
    }
    public void moveleft(){

            this.People.setRefPixelPosition(this.People.getRefPixelX()-this.Speed,this.People.getRefPixelY());

    }
    public void moveright(){
        this.People.setRefPixelPosition(this.People.getRefPixelX()+this.Speed, this.People.getRefPixelY());
        
    }
    public void moveup(){
        this.nextpeopleY = 2*this.peopleY - this.prepeopleY +this.peak;
        this.People.setRefPixelPosition(this.People.getRefPixelX(),(int)this.nextpeopleY);
        this.prepeopleY = this.peopleY;        
        this.peopleY = this.nextpeopleY;

    }
    public void setSpeed(int Speed){
        this.Speed = Speed;
    }
    public void setPeopleYY(float peopleY,float prepeopleY ){
        this.peopleY = peopleY;
        this.prepeopleY = prepeopleY;
    }
}

⌨️ 快捷键说明

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