?? wombatactor.java
字號:
import javax.microedition.lcdui.Graphics;
/**
* The main player actor, the Wombat.
* @author Martin J. Wells
*/
public class WombatActor extends Actor
{
/**
* Constructs a new WombatActor object using the specified GameScreen and
* position.
* @param gsArg The GameScreen this Actor is associated with.
* @param xArg The x starting position.
* @param yArg The y starting position.
*/
public WombatActor(GameScreen gsArg, int xArg, int yArg)
{
super(gsArg, xArg, yArg);
}
/**
* Renders the actor to the screen by drawing a rectangle.
* @param graphics The graphics context to draw to.
*/
public void render(Graphics graphics)
{
graphics.setColor(0x0044FF44);
graphics.fillRect(getX(), getY(), getActorWidth(), getActorHeight());
}
/**
* An overridden version of the Actor setX method in order to stop the
* wrapping it does. You want the wombat to stop on the edge of the screen.
* @param newX The new x position.
*/
public void setX(int newX)
{
super.setX(newX);
// non-wrapping version for the wombat
if (getX() < 0)
setX(0);
if (getX() > gameScreen.getWidth()-getActorWidth()-2)
setX(gameScreen.getWidth() - getActorWidth()-2);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -