📄 caractor.java
字号:
import javax.microedition.lcdui.Graphics;
/**
* An VehicleActor that represents a little car (the only customisation is the
* size and the drawing code).
* @author Martin J. Wells
*/
public class CarActor extends VehicleActor
{
/**
* Constructs a new car setting the GameScreen, starting position (x, y)
* and the speed at which it should move.
* @param gsArg GameScreen Actor is associated with.
* @param xArg The starting x position.
* @param yArg The starting y position.
* @param speedArg The speed of the vehicle.
*/
public CarActor(GameScreen gsArg, int xArg, int yArg, int speedArg)
{
super(gsArg, xArg, yArg, speedArg);
}
/**
* Get the Actor width (overriden to set the width properly).
* @return The width of the car.
*/
public int getActorWidth()
{
return 12;
}
/**
* Draws a car using rectangles.
* @param graphics The graphics context on which to draw the car.
*/
public void render(Graphics graphics)
{
int u = getActorHeight();
graphics.setColor(0x00aa9922);
graphics.fillRect(getX(), getY(), u, u);
graphics.fillRect(getX() + (u / 2) + 5, getY(), u, u);
graphics.setColor(0x00ffcc66);
graphics.fillRect(getX() + u - 2, getY(), u, u);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -