?? peopleclass.java
字號:
/*
* 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;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -