Hero.java
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:

J2ME

开发平台:

Java

  1. import javax.microedition.lcdui.Image;
  2. import javax.microedition.lcdui.game.Sprite;
  3. public class Hero
  4. {
  5.         private Image image;
  6.         public Hero()
  7.         {
  8.         }
  9.         public void load()
  10.         {
  11.                 try
  12.                 {
  13.                         image = Image.createImage("/hero.png");
  14.                 }
  15.                 catch (Exception e)
  16.                 {
  17.                         e.printStackTrace();
  18.                 }
  19.         }
  20.         public Sprite getHero()
  21.         {
  22.                 Image tmp = null;
  23.                 try
  24.                 {
  25.                         tmp = Image.createImage(image, 0, 0, 72, 116, Sprite.TRANS_NONE);
  26.                 }
  27.                 catch (Exception e)
  28.                 {
  29.                         e.printStackTrace();
  30.                 }
  31.                 Sprite hero = new Sprite(tmp, 24, 29);
  32.                 return hero;
  33.         }
  34. }