Image.createImage exception
Hi all, I have problem with loading image to my application. If I create image with methodImage.createImage(String name)everything is ok and image shows up, but when I want to use just part of this image and I call methodImage.createImage(Image image, int x, int y, int width, int height, int transform)the Exception is thrown.
Part of my code:
- works correct:
try {
String name = "name.png";
Image img = Image.createImage(name);
g.drawImage(img, imageX, imageY, 0);
} catch (IOException ioex) {
System.err.println(ioex);
}- throws Exception:
try {
String name = "name.png";
Image img = Image.createImage(name);
img = Image.createImage(img, 0, 0, img.getWidth(), img.getWidth(), Sprite.TRANS_NONE); // the whole image is 26x364 and I'd like to use just 26x26 from the top left corner
g.drawImage(img, imageX, imageY, 0);
} catch (IOException ioex) {
System.err.println(ioex);
} catch (IllegalArgumentException iaex) {
System.err.println(iaex);
}Any idea what could be wrong? Thank you.
I'm not sure. But can you give the size of the image without creating it and the code does not understand.
eg
img = Image.createImage (img, 0, 0, 26, 364, Sprite.TRANS_NONE);
Similar Messages
-
Problem with Image.createImage()
Hi all!
I'm writing a simple midlet just to display an image on the screen and I'm having some problems with Image.createImage()
Here is my code
Image bg_img;
ImageItem imageItem1;
imageItem1 = new ImageItem("", null,ImageItem.LAYOUT_DEFAULT, "");
try{
bg_img = Image.createImage("/image.png");
imageItem1.setImage(bg_img);
catch(java.io.IOException e){
e.printStackTrace();
I'm getting an exception on bg_img = Image.createImage("/image.png");
I can't understand what is it...:(
I know for sure that the problem is not "file not found"
Any one can help me???If you are catching IOException, then u may have problem with ur image path. "image not found on the specified path." if ur image is not in the current directiry then put it into current directory. otherwise, If u are using resouce folder and it is already included into the resouce path, then put ur image in that folder..try this..
Still not get, then please give some detail about ur development toolkit. and ur apllication packaging scheem. are you using ANT?
Pranav -
Image.createImage() on benq-siemense M81 and SE z530i (using google maps)
I'm getting static google maps to show them in my j2me application. There is one problem...
Code for shoing image:
try {
byte[] preimage = gm.retrieveStaticImage(<params>);
this.my_image = Image.createImage(preimage, 0, preimage.length);
this.getImageItem().setImage(my_image);
} catch (Exception ex) {
ex.printStackTrace();
}Data coming to preimage. Size of it is OK. But Image.createImage() method doesnt work on z530i. I dont see any messages with exceptions... Whats wrong? Maybe data format? I tryed GIF, JPG, PNG32. Result is the same...
PS
Images from other resources (not google maps) loading whithout problems.
Edited by: fewl on Aug 14, 2008 3:19 PMHello
I rooted my Sony Ericsson Arc S by following your excellent and easy to understand instuctions in order to remove some of the unwanted crap that came preloaded on the phone and in order to install the rooted version of Avast antivirus/antitheft app.
Everything has worked perfectly well for the last few months since doing this however now I am unable to update the phone via the sony ericsson update service.
Please advise
Cheers
Ian -
IllegalArgumentException in Image.createImage()
Hello,
I have a problem trying to create an image-object from a captured snapshot as I always get an IllegalArgumentException in Image.createImage when capturing with 640x480. My code looks like:
raw = mVideoControl.getSnapshot("encoding=jpeg&width=640&height=480");
Image img = Image.createImage(raw, 0, raw.length);When I capture with 320x240, everything's fine. I guess this is a bug with my phone (Siemens S65), but would anyone have an idea how to work around that one? I thougt of doing some kind of a "screenshot", but couldn't figure out how and if this is possible.
Thanks a lot for any help or hints
TobiasI am absolutely sure, the actual code looks like:
byte[] raw = mVideoControl.getSnapshot(enc);
Image img = null;
try {
img = Image.createImage(raw, 0, raw.length);
} catch (Throwable t) {
showAlert(t.toString());
System.out.println(t.toString());
}showAlert() is my own convenience method for showing an Alert. I also send the image-byte[] to a server where I save it to a file and this works perfectly... So the Exception is definitely from createImage().
Tobias -
Image.createImage() problem with eclipseME IDE
I create directory struture like this:
PhotoView
|- class
|- deployed
|- res
|- src
|- verified
Images was put in res.
However, I am allways catched exception with the bold line.
Please, help me.
Thanks.
private void showImage(int index) {
imageForm.deleteAll();
Image img;
try {
img = Image.createImage("/pBirds.png");
} catch (Exception e) {
img = null;
e.printStackTrace();
ImageItem imgItem = new ImageItem("pBirds.png", img,
ImageItem.LAYOUT_CENTER, "Image");
imageForm.append(imgItem);
display.setCurrent(imageForm);
}Maybe you should try to add the res folder to your project path?
project properties-> build path add folder.... -
Image.createImage() IOException on certain file other files work :|
Hi from newbie :)
I writing this simple game and i have occured this strange problem.
I can't read my file from the /res dir. However i can read a file that i have used in a tutorial. The file that i have problem with was created by me, it's a simple *.gif file (i used MS paint if that matters). The file that i can read was provided by a tutorial it's also a *.gif file. Here is a part of my code:
public void start()
try
playerImg = Image.createImage("/player.gif");
playerX = CENTER_X;
playerY= CENTER_Y;
catch(NullPointerException nullEx)
System.err.println("NullPointerException data");
System.err.println(nullEx);
System.err.println(nullEx.getMessage());
nullEx. printStackTrace();
catch(IOException ioex)
System.err.println("IOException data");
System.err.println(ioex);
System.err.println(ioex.getMessage());
ioex. printStackTrace();
Thread runner = new Thread(this);
runner.start();
}This a msg from exception:
IOException data
java.io.IOException
null
Uncaught exception java/lang/NullPointerException: .
java.io.IOException
at javax.microedition.lcdui.Image.createImage(+17)
at MyGameCanvas.start(+6)
at AdventureGameMIDlet.startApp(+12)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
at com.sun.midp.midlet.Scheduler.schedule(+270)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+116)
I'm using SonyEricsson J2ME SDK WTK2 for P900 if that matters.
Also i have one more question why this exception is not caught by the catch(NullPointerException nullEx) {...} clause?
For any help i'll be grateful :)Main class with std MIDlet methods
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.Display;
public class AdventureGameMIDlet extends MIDlet
MyGameCanvas gCanvas;
public AdventureGameMIDlet()
gCanvas = new MyGameCanvas();
public void startApp()
Display display = Display.getDisplay(this);
gCanvas.start();
display.setCurrent(gCanvas);
public void pauseApp()
public void destroyApp(boolean unconditional)
}Class for the game:
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;
import java.io.IOException;
import java.lang.NullPointerException;
import java.lang.Thread;
public class MyGameCanvas extends GameCanvas implements Runnable
// the couple image
private Image playerImg;
// the couple image coordinates
private int playerX;
private int playerY;
// the distance to move in the x axis
private int dx = 1;
// the center of the screen
public final int CENTER_X = getWidth()/2;
public final int CENTER_Y = getHeight()/2;
public MyGameCanvas()
super(true);
public void start()
try
playerImg = Image.createImage("/player.png");
playerX = CENTER_X;
playerY= CENTER_Y;
catch(NullPointerException nullEx)
System.err.println("NullPointerException data");
System.err.println(nullEx);
System.err.println(nullEx.getMessage());
nullEx. printStackTrace();
catch(IOException ioex)
System.err.println("IOException data");
System.err.println(ioex);
System.err.println(ioex.getMessage());
ioex. printStackTrace();
Thread runner = new Thread(this);
runner.start();
public void run()
Graphics g = getGraphics();
while(true)
verifyGameState();
checkUserInput();
updateGameScreen(getGraphics());
try
Thread.currentThread().sleep(30);
catch(Exception ex)
private void verifyGameState()
//code
private void checkUserInput()
int keyState = getKeyStates();
calculateCoupleX(keyState);
private void updateGameScreen(Graphics g)
g.setColor(0xffffff);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(playerImg, playerX, playerY, Graphics.HCENTER | Graphics.BOTTOM);
flushGraphics();
private void calculateCoupleX(int keyState)
if((keyState & LEFT_PRESSED) != 0)
playerX -= dx;
else if((keyState & RIGHT_PRESSED) != 0)
playerX += dx;
} -
Hi! Im downloading images from server , but im getting IO exception after few images downloaded....whats wrong?
for (int i=0;i<10;i++)
try{
conn=(HttpConnection)Connector.open(rez.substring(0,y));//this is current url
in=conn.openInputStream();//opening input stream
im=Image.createImage(in);// creating image
elements.p3=im;//save it
news.append(im);//show it
catch (Exception e){m1.append("Reading image "+e.toString()+"\n");}give me a full desc of the exception
-
How do i backup the list of load images automatically exceptions under Options->Content. I want to transfer to another comp without re-adding one at a time. EVen if there is no way to backup, what is the system file for Firefox that stores these, so i can transfer this file or open it in an XML or similar editor to copy them out?
The permissions.sqlite file stores 'allow' and 'block' exceptions for cookies, images, pop-up windows, and extensions (software) installation.
*http://kb.mozillazine.org/Profile_folder_-_Firefox
You can use this button to go to the Firefox profile folder:
*Help > Troubleshooting Information > Profile Directory: Show Folder
See also:
*https://support.mozilla.org/kb/Recovering+important+data+from+an+old+profile
*http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox -
Image.createImage() crashed in Nokia 7210 Emulator
Dear all,
I'm developing a midlet for showing png file on a canvas by the 7210 emulator.
whenever I call the Image.createImage("/myfile.png"), the midlet will shown "Unable to run application" and then exit the midlet application. My png file's size is 734 bytes (140x100 pixel).
When I test the programme by other emulator, ie. 7650, default color phone and so on, the programme runs smoothly.
Does anyone know how to solve this problem??
joey829From your experience I think maybe the emulator have some bugs. Try to download updated emulator from nokia. Or try as many emulator as you can. In most cases different company though build different emulator, their work behavior should be identical with the same program.
-
Image.createImage(inputstream) not work in mobilityback
hi,
Guys, while using MIDlet with WTK tool its working fine and dowload the image from corresponding URL (using Image.createImage(inputstream obj) ).
The same code was used in mobilityback error like "cannot resolve symbol createImage(inputstream) "
This error only on while build the project not in compiling particular midlet file.
What may be the problem please any idea?hi,
one more thing
The same method working fine in WTK emulator as well as netBeans also, while using it with j2mepolish the error arise at the time of build project(The seperate file is compiling properly).
what i have to do with polish ? -
Why don't you make the image classification except the computer?
Why don't you make the image classification except the computer?
Please try posting in your native language. This question make no sense.
-
Image is NULL exception, problems displaying a png file
Hi people,
I want to display a simple image using j2me on my siemens sl45i emu.
I'm using the following code to load my png 8x8(created with photoshop, 2bpp) image:
public void load()
try
testImage = Image.createImage("res/enemy1.png");
catch (Exception e)
System.err.print("Ladefehler: " + e);
when I want to display the image using the follwing code:
private void render(Graphics g)
g.drawImage(testImage,0,0,0);
g.drawString("**** you!", 0, 0, Graphics.TOP|Graphics.LEFT);
I'm getting the following exception:
java.lang.NullPointerException: Image is null.
Why do I get this exception when I want to display the image and not when I'm loading the image(something like "couldn't load image..." )....
I've placed enemy1.png in a folder called "res" in my jar file. Displaying text does work so I don't understand why I can't display an image...
Any help would be great!
Thanx in advance, alexThis can't be possible!
private void load()
GameGraphics.getInstance().load();
Player.getInstance().load();
I'm printing debug messages in both load()-methods and I'm getting an exception in the player class because gamegraphics didn't finish loading (I can see it from the debugging messages) -
ArrayIndexOutOfBound Exception for image
Hi All,
I my application i want to convert image into inverted format.So for this i have written this code.
ParameterBlock pb = new ParameterBlock();
pb.add(bufferedImage);
PlanarImage im = (PlanarImage)JAI.create("awtImage", pb);
ParameterBlock pb1 = new ParameterBlock();
pb1.addSource(im);
PlanarImage newImage = JAI.create("invert", pb1);
ParameterBlock pb2 = new ParameterBlock();
pb2.addSource(newImage);
pb2.add(jpegFilePath);
pb2.add("jpeg");
pb2.add(null);
pb2.add(true);
RenderedOp op = JAI.create("filestore", pb2,null);
But i am getting this error while storing image.
java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
at sun.awt.image.BytePackedRaster.getByteData(BytePackedRaster.java:378)
at sun.awt.image.BytePackedRaster.getDataElements(BytePackedRaster.java:273)
at java.awt.image.BufferedImage.getData(BufferedImage.java:1415)
at javax.media.jai.RenderedImageAdapter.getData(RenderedImageAdapter.java:158)
at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:794)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.copyData(PlanarImage.java:2343)
at javax.media.jai.RenderedOp.copyData(RenderedOp.java:2299)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2525)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)
If any one knows how to invert image using JAI or java please reply me as soon as possible
Thanks & Regsrds
AP_javaHi, Thanks for your reply.
But seeing the 2nd println statement is not my point. I was trying to point out that the NullPointerException caused within Image.createImage could not be caught even when i enclosed only the statement within a try-catch. This is not good because my users will get a shock when they see the exception.
Maybe there is a bug in the Image.createImage method. I will go log a bug in the bugbase later.
But anyway, i observe that this exception does not occur all the time. It only happen after i print a few images and more often when i use color. I guess it's a memory issue here.
So i went around it by reducing the memory usage of my app and using less colors. Up to 256 colors is quite safe. -
MIDP 1.0: Image to byte[] or serializing...
I would like to extract pixels from a MIDP 1.0 "Image" object through any means possible. I am currently under the impression that "Image.toString()" would just do something lame, like giving me a string like "Image@1234" that identifies the class and the instance -- which could in principle be used for mere instance comparison. Anyhow, if I could serialize an Image object to a file, and then read back the file in to a byte array, then I would be delighted. I want to stress that I don't care how convoluted the approach may be, as long as it is in plain-vanilla J2ME Java code for MIDP 1.0 and is capable of working on an actual device (as opposed to an emulator). Can I cast the Image to Object, and then somehow convert to byte[]? I don't care if I have to get down and dirty, hacking the platform-specific bytes of the full Object manifestation of the Image. Anyhow, I want to make it clear that any hard core hack, doing all kinds of things that would break on different VMs, etc, is totally fine. Messy is fine. I just want access to the binary data of the entire Image object, or, even better (but only icing on the proverbial cake), access to pixel data. If I can get the byte[] representation of Image, then I can hack the rest myself.
My goal was do a capture of the way things actually rendered on a device, kind of like a "screen capture", only a little more indirect (since I don't think there is a way to get access to the pixels of the LCD). What I have to do is render to an off-screen Image object and then retrieve pixel data from it using the platform-dependent getPixels() supplied by Motorola. You're going to think I'm crazy, but I send this image data to a web server via POSTs, which get collected and stored as a single file on my web server. Voila! A screen capture of how things actually render to an Image object on an actual device.
Everything works, except...
I can't get the Motorola "getPixels()" method to work in their emulator, so I'm worried
that it won't work on my Motorola T720 (something I haven't actually tried, though).
I get a "Uncaught Exception: java/lang/Error" message from the T720 emulator
when I run one of the Motorola demos (built using their scripts) when I add the
following code to the Canvas paint() method:
if (0 == iDidThis) { iDidThis = 1;
try
{ javax.microedition.lcdui.Image temp = Image.createImage( 120, 160 );
int [] rgbData = new int [120*160];
com.motorola.game.ImageUtil.getPixels ( temp, 0, 0, 1, 1, rgbData );
System.out.println("Captured Data");
catch( java.lang.ArrayIndexOutOfBoundsException e )
{ e.printStackTrace(); } }
This code runs only once, when the paint() method of the Canvas object is called for
the first time. Okay, I get the error message, but the "Bounce" demo (to which I added
the code block above) goes on to run just fine. (NOTE: The message "Captured Data"
is NOT printed in this scenario.)
I don't understand why the public static "com.motorola.game.ImageUtil.getPixels()"
method causes the "java/lang/Error" exception. (By the way, if I comment out the
call to this method, the code totally works without error, and I see the printed
statement "Captured Data" in the command window associated with the emulator.)
If my getPixels() call resulted in bad array access, then I would get the
java.lang.ArrayIndexOutOfBoundsException exception. But apparently this is
not what is going on.
I am really rusty with J2ME, so I don't even know the meaning of "java/lang/Error".
I assume it is different from a "class not found" exception, but I suspect that my
problem has to do with a fault in the emulator trying to execute the code for the
"com.motorola.game.ImageUtil.getPixels()" method.
My Motorola emulator (v7.5) is from around December, 2002, so it may be really old, and
maybe this was a known issue at that time that has since been resolved. I'm just never
tried to use platform-specific J2ME APIs before, so I don't know if what I am observing
is my fault, or is an emulator issue.
I'd be grateful for any ideas about what might be going wrong and for ideas about
possible solutions. -
Display a strip of images in a single keyPress?
i am having a strip of images which contain 16 images .my problem is i jus want to show entire frames in a single keypress
now i m getting each frame in a keypress
***********here is my code***************
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public class ExampleGameCanvas extends GameCanvas implements Runnable
private boolean isPlay; // Game Loop runs when isPlay is true
private long delay=8; // To give thread consistency
private int k;
private int counter=0;
private int xpos=50;
private int ypos=60;
private byte ROTATE_NONE = Sprite.TRANS_NONE;
private byte ROTATE_90 = Sprite.TRANS_ROT90;
private byte ROTATE_180= Sprite.TRANS_ROT180;
private byte ROTATE_270= Sprite.TRANS_ROT270;
private byte CURRENT_ROTATE=ROTATE_NONE;
private Image clwalk;
private Image tilesImg,bottomboard,clownIdle; //Image varibale declaration-kris
private int clwalkXstart;
private int clnX=0;
private int tileXPos = 0;
private int tileYPos = 150;
private byte tileWidth = 21;
private byte tileHeight = 21;
private int tileStartXPosition = 0;
private int tileStartYPosition = 0;
private int numberOfRows = 12;
private int numberOfColumns = 11;
private int tileStartY = 39;
private boolean walk=false;
private int count=0;
private int p=0;
private int sampleMap[][] = {
//1, 2, 3, 4, 5, 6, 7, 8, 9,10,11
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, //11x12
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1, 1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, //-1 for empty space
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0} //0 for square tile
private int current_Map[][] = new int[numberOfRows][numberOfColumns]; //this will store the current level
// Constructor and initialization
public ExampleGameCanvas()
super(true);
try
tilesImg = Image.createImage("/tiles_240x320.png");
bottomboard = Image.createImage("/bottomboard_240x320.png");
clwalk = Image.createImage("/cl_walk_240x320.png");
}catch(Exception ee){}
// Automatically start thread for game loop
public void start()
isPlay = true;
Thread t = new Thread(this);
t.start();
// Main Game Loop
public void run()
Graphics g = getGraphics();
while (isPlay == true)
input();
drawMap(g);
drawPlayer(g);
try { Thread.sleep(delay); }
catch (InterruptedException ie) {}
// Method to Handle User Inputs
private void input()
int keyStates = getKeyStates();
// Right
if ((keyStates & RIGHT_PRESSED) !=0 )
clwalkXstart +=26;
if(clwalkXstart==416)
clwalkXstart=0;
clnX+=2;
else if ((keyStates & LEFT_PRESSED) !=0 )
walk=true;
System.out.println("1111111111111111111111111111111111");
clnX-=3;
private void drawMap(Graphics g)
System.out.println("jjjjjjjjjjjjjjjjjjjjjjj");
System.out.println("oooooooooooooooooooo");
g.setClip(0, 0, getWidth(), getHeight());
g.drawImage(bottomboard, 0, getHeight()-bottomboard.getHeight(), 0);
current_Map=sampleMap;
for(byte row = 0; row < numberOfRows; row++)
for(byte col =0; col < numberOfColumns; col++)
switch(current_Map[row][col])
case 0:
g.drawRegion(tilesImg, tileStartXPosition, tileStartYPosition, tileWidth, tileHeight, ROTATE_NONE, tileXPos,220, Graphics.TOP|Graphics.LEFT);
break;
if(tileXPos < 215)
tileXPos += tileWidth;
else
tileXPos = 5;
if(row >= 11)
tileYPos = tileStartY;
else
tileYPos += tileHeight;
// repaint();
// flushGraphics();
private void drawPlayer(Graphics g)
g.setColor(0xffffff);
g.fillRect(0,0,getWidth(),179+clwalk.getHeight());
g.drawRegion(clwalk,clwalkXstart, 0, 26, 41, ROTATE_NONE, clnX,180, Graphics.TOP|Graphics.LEFT);
try {
Thread.sleep(40);
} catch (InterruptedException ex) {
ex.printStackTrace();
flushGraphics();
repaint();
}hi
i solved the problem.now my problem is i have to move my player(actor) according to the map
**********here is my code**************
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
public class clsCanvas extends GameCanvas implements Runnable
private boolean isRunning = true;
private Graphics g;
private midMain fParent;
private Image clwalk;
private int clwalkXstart;
private int clnX=0;
private boolean playerRunning = false;
/*************FOR TILED MAP**************************/
private Image tileMap,bottomboard;
private int numberOfRows = 12; //index of rows
private int numberOfColumns = 11; //index of cols
private int tileStartXPosition= 0;
private int tileStartYPosition= 0;
private byte tileWidth = 21;
private byte tileHeight = 21;
private int tileXPos = 5;
private int tileYPos = 0;
private int tileStartY = 39;
private int sampleMap[][] = {
//1, 2, 3, 4, 5, 6, 7, 8, 9,10,11
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1, 0,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1, 0,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1, 1, 0, 2,-1,-1,-1,-1},
{-1,-1,-1, 1, 0, 0, 0, 2,-1,-1,-1},
{-1,-1, 1, 0, 0, 0, 0, 0, 2,-1,-1},
{-1, 1, 0, 0, 0, 0, 0, 0, 0, 2,-1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
private int current_Map[][] = new int[numberOfRows][numberOfColumns]; //this will store the current level
/***********MAP VARIABLES ENDS HERE*****************/
public clsCanvas(midMain m) //constructor to initilization
super(true);
fParent=m;
try {
clwalk = Image.createImage("/cl_walk_240x320.png");
tileMap = Image.createImage("/tiles_240x320.png");
bottomboard = Image.createImage("/bottomboard_240x320.png");
} catch (IOException ex) {
ex.printStackTrace();
public void start() //start game thread here
Thread runner = new Thread(this);
runner.start();
public void run()
{ //run method
int iKey = 0;
g = getGraphics();
while(isRunning)
drawMap(g);
drawPlayer(g);
iKey = getKeyStates();
if ((iKey & GameCanvas.RIGHT_PRESSED) != 0) //keyPress_RIGHT
playerRunning = true;
System.out.println("right_key_pressed");
if(playerRunning) {
moveStrip();
flushGraphics();
try {
Thread.sleep(30);
} catch (Exception ex) { }
}//while ends here
g = null;
fParent.destroyApp(false);
fParent = null;
}//run ends here
private void drawMap(Graphics g)
current_Map=sampleMap;
g.setColor(0x000000);
g.fillRect(0,0,getWidth(),getHeight());
g.setClip(0, 0, getWidth(), getHeight());
g.drawImage(bottomboard, 0, getHeight()-bottomboard.getHeight(), 0);
for(byte row = 0; row < numberOfRows; row++)
for(byte col =0; col < numberOfColumns; col++)
switch(current_Map[row][col])
case 0:
g.drawRegion(tileMap, tileStartXPosition, tileStartYPosition, tileWidth, tileHeight, 0, tileXPos, tileYPos-55, Graphics.TOP|Graphics.LEFT);
System.out.println(tileYPos);
System.out.println("tileXpos-"+tileXPos);
break;
if(tileXPos < 215)
tileXPos += tileWidth;
else
tileXPos = 5;
if(row >= 11)
tileYPos = tileStartY;
else
tileYPos += tileHeight;
private void drawPlayer(Graphics g) //drawPlayer() Method [called by run()]
/* g.setColor(0x000000);
g.fillRect(0,0,getWidth(),getHeight());*/
g.drawRegion(clwalk,clwalkXstart, 0, 26, 41, 0, clnX,155, Graphics.TOP|Graphics.LEFT);
try {
Thread.sleep(40);
} catch (InterruptedException ex) {
ex.printStackTrace();
}//DrawPlayer ends here
private void moveStrip() //moveStrip() method [called by run()]
clwalkXstart +=26; //clipX updating to 26
if(clwalkXstart==390) {
clwalkXstart=0;
playerRunning = false;
clnX +=2; //increasing the destinationX to 2
}
Maybe you are looking for
-
Time Machine doesn't restore my Business Folder in Mail, which is empty after I installed Mavericks. It will restore just the folder but nothing in it. What am I doing wrong? Also, Time Machine doesn't go back more than about a year. I thought it wou
-
Issue in Posting of Vendor Invoice
Hi I am having an issue in posting of vendor invoice. In simulation mode, the system is showing the correct calculation of TDS amounts. but when I am trying to post the Invoice , the TDS entries created by the system are deleted and system gives: Err
-
Upgrade BI Content Level 0000 to 0008
Hi, I have posted this to BI with no responses so I'm posting here in hopes some Basis person might be able to help. We currently have BI Content BI_CONT 7.03 0000 (Level 0). I would like to have the latest Business Content Level for Statistics.
-
Why do I have to reset shuffle Mode every time I change playlists?
Subject:
-
Help, please. (iCloud storage full when it shouldn't be)
Hi folks. Need help re: iCloud storage. I own two Macs, an iPad (3rd gen), and iPhone 5. None of these uses iCloud for backups. My apps only take up about 20MB, and Mail takes up 407.8MB. And yet Settings says that my iCloud storage is full! I'm stum