⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 truckactor.java

📁 大量j2me源代码
💻 JAVA
字号:
import javax.microedition.lcdui.Graphics;

/**
 * An VehicleActor that represents a truck (the only customisation is the
 * size and the drawing code).
 * @author Martin J. Wells
 */
public class TruckActor extends VehicleActor
{
   /**
    * Constructs a new truck 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 TruckActor(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 truck.
    */
   public int getActorWidth()
   {
      return 28;
   }

   /**
    * Draws a truck using rectangles.
    * @param graphics The graphics context on which to draw the car.
    */
   public void render(Graphics graphics)
   {
      int u = getActorHeight();

      // the front
      graphics.setColor(0x00aa9922);
      graphics.fillRect(getX(), getY(), 4, u);
      // the trailer
      graphics.setColor(0x00aa9922);
      graphics.fillRect(getX()+9, getY(), 18, u);
      // the cab
      graphics.setColor(0x00ffcc66);
      graphics.fillRect(getX() + 4, getY(), u-3, u);

   }
}

⌨️ 快捷键说明

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