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

📄 wombatactor.java

📁 j2me游戏编程光盘源码
💻 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 + -