Computer Science Canada need help in changing a dot image to a .PNG image on the resource folder |
Author: | von5leyz [ Sun Nov 20, 2011 7:09 am ] |
Post subject: | need help in changing a dot image to a .PNG image on the resource folder |
//need help in changing a dot image to a .PNG image on the resource folder //how can i change the code below and make it a code that instead of creating a dot image it will create or call the .PNG image file on the resource folder // below is the source code package pucman; import javax.microedition.lcdui.*; import javax.microedition.lcdui.game.*; public class Dot extends Sprite { protected int score; protected static Image dotImage; //protected static Image gennumber; public int getScore() { return score; } public static Image getImage() { try { //gennumber = Image.createImage(8,8); dotImage = Image.createImage(6,6); Graphics g = dotImage.getGraphics(); // Graphics g = gennumber.getGraphics(); g.setColor(0xffffffff); g.fillRect(0, 0, dotImage.getWidth(), dotImage.getHeight()); } catch (Exception e) { System.err.println("Error loading dot image"); return null; } //return dotImage; return dotImage; } public Dot(Position position) { super(getImage()); this.score = 10; setPosition(position.getX()-getWidth()/2,position.getY()-getHeight()/2); } } |