?? ball.java
字號:
/*
* Ball.java
*
* Created on 2006年3月13日, 下午2:21
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
package Creature;
import Snowball.*;
import java.lang.Math;
import java.util.Random;
import javax.microedition.lcdui.game.Sprite;
/**
*
* @author Administrator
*
*/
public class Ball extends Creature{
/*
* 參數
*/
private int Vx;//水平速度
private int Vy;//垂直速度
public int BallPower; //子彈能量 初始能量
public int BallDistance;//子彈距離 初始射程 10 加長后 15
//臨時坐標記錄
public int TempX ;
public int TempY ;
/** Creates a new instance of Ball */
public Ball(int x, int y, int WalkDir, Sprite ImageL, Sprite ImageR)
{
super(x, y, WalkDir, ImageL, ImageR);
//設置子彈參數
//速度
Vx = 8;
Vy = 1;
//幀的寬,高
frameWidth = 25;
frameHeight = 5;
//狀態
State = false; //邏輯狀態
DrawState = false;//繪畫狀態
//射程
BallDistance = 50;
//子彈能量
BallPower = 10;
}
public void Process(int TickCount){
Move(WalkDir);
CheckBallDistance();
}
//移動
private void Move(int WalkDir){
switch(WalkDir){
case 0:
//水平
x = x - Vx;
//垂直
y = y + Vy;
break;
case 1:
//水平
x = x + Vx;
//垂直
y = y + Vy;
break;
}
}
//判斷子彈射程
private void CheckBallDistance(){
if( Math.abs(x - TempX) >= BallDistance ){
State = false; //邏輯狀態
DrawState = false;//繪畫狀態
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -