jar from website

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

jar from website

Postby rahul7star » Sun Oct 28, 2007 10:31 am

Hi
well m having a jad file(in desktop) in which i had given my jar url (http:/rahul7star.googlepages.com/img.jar) , but jad file could not load this jar from my website. so how one can load jar from website

However if i copy this jar from my website and change "MIDlet-Jar-URL" path to MIDlet-Jar-URL:Img.jar
and put it into my desktop then its working.
error name is "uncaught exception java/lang/IndexOutOfBoundsException"


my jad file is like this
MIDlet-1: ImmutableImage1, , ImmutableImage1
MIDlet-Jar-Size: 12276
MIDlet-Jar-URL: http:// rahul7star . googlepages . com // Edited by Codetiger: [Avoid links in your posts please...] remove spaces before you test
MIDlet-Name: Img
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.1
Last edited by rahul7star on Mon Oct 29, 2007 4:53 pm, edited 2 times in total.
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: jar from website

Postby DevelopmentTeam » Sun Oct 28, 2007 10:56 am

Are you speaking about opening jad using Emulator?

In that case, I dont think the emulator will run from the website.

but incase of a mobile it will download it with no problem I think...
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: jar from website

Postby rahul7star » Sun Oct 28, 2007 11:07 am

Hi
Yes it workd from emulator , i had change d path to
MIDlet-Jar-URL: http:// rahul7star . googlepages . com / Img . jar // Edited by Codetiger: Removed clickable links

and it workd.

but one thing i would like to ask what is the use of setFrame()

actuly m having 4 face of my charcter when user press left arrow key then i waant to to show left image of my player . so how setFrame(1) , setFrame(2) can help.
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: jar from website

Postby DevelopmentTeam » Sun Oct 28, 2007 11:17 am

You probably have to use a sprite image where each frame should have different faces as you like. And you can simply draw the sprite in Paint function and change the frame using sprite.setframe in keypressed event to show which frame you like on what key..
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: jar from website

Postby rahul7star » Sun Oct 28, 2007 11:29 am

Hi i mor thing
well i waant to use the hole screen of emulator to display my image
but currently m using image of dimension 177/208 and if i inc the size of image then error occurs. Is ther ny resctriction for images

my image name is-"image141.jpg"


and here is my code

Code: Select all
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; // To give thread consistency
private int currentX, currentY; // To hold current position of the 'X'
private int width; // To hold screen width
private int height; // To hold screen height
// Sprites to be used
private Sprite playerSprite;
private Sprite backgroundSprite;
// Layer Manager
private LayerManager layerManager;
// Constructor and initialization
public ExampleGameCanvas() throws Exception {
super(true);
width = getWidth();
height = getHeight();
currentX = width ;
currentY = height;
delay = 20;
// Load Images to Sprites
Image playerImage = Image.createImage("/mainscrn.png");
playerSprite = new Sprite (playerImage,32,32);
Image backgroundImage = Image.createImage("/image141.jpg");
backgroundSprite = new Sprite(backgroundImage);
layerManager = new LayerManager();
layerManager.append(playerSprite);
layerManager.append(backgroundSprite);
}
// Automatically start thread for game loop
public void start() {
isPlay = true;
Thread t = new Thread(this);
t.start();
}
public void stop() { isPlay = false; }
// Main Game Loop
public void run() {
Graphics g = getGraphics();
while (isPlay == true) {
input();
drawScreen(g);
try { Thread.sleep(delay); }
catch (InterruptedException ie) {}
}
}
// Method to Handle User Inputs
private void input() {
int keyStates = getKeyStates();
playerSprite.setFrame(0);
// Left
if ((keyStates & LEFT_PRESSED) != 0) {
currentX = Math.max(0, currentX - 1);
playerSprite.setFrame(0);
}
// Right
if ((keyStates & RIGHT_PRESSED) !=0 )
if ( currentX + 5 < width) {
currentX = Math.min(width, currentX + 1);
playerSprite.setFrame(0);
}
// Up
if ((keyStates & UP_PRESSED) != 0) {
currentY = Math.max(0, currentY - 1);
playerSprite.setFrame(0);
}
// Down
if ((keyStates & DOWN_PRESSED) !=0)
if ( currentY + 10 < height) {
currentY = Math.min(height, currentY + 1);
playerSprite.setFrame(0);
}
}
// Method to Display Graphics
//private void drawScreen(Graphics g) {
//g.setColor(0x00C000);
private void drawScreen(Graphics g) {
//g.setColor(0x00C000);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0xffff00);
// updating player sprite position
playerSprite.setPosition(currentX,currentY);
// display all layers
layerManager.paint(g,0,0);
flushGraphics();
}
}
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: jar from website

Postby DevelopmentTeam » Sun Oct 28, 2007 11:36 am

The screen size of the emulator is around 240x320 and you can use such a big images as PNG and advisable upto 25Kb... I dont think there will be nay problem in this case.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: jar from website

Postby DevelopmentTeam » Sun Oct 28, 2007 11:37 am

I would also like to know about what error you are getting... So that we can predict the issue...
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: jar from website

Postby rahul7star » Sun Oct 28, 2007 11:53 am

If i try to move background using setFrame() or ny image having dimension > 177/208
then " Uncaught exception java/lang/IndexOutOfBoundsException."
error occurs
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: jar from website

Postby rahul7star » Sun Oct 28, 2007 12:06 pm

other error which m geeting is

java.lang.IllegalArgumentException
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: jar from website

Postby DevelopmentTeam » Mon Oct 29, 2007 3:06 am

to move the background you need to use setposition and not setframe...

setframe is just to show a purticular frame and if you want to move it you need to user setposition..
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: jar from website

Postby rahul7star » Mon Oct 29, 2007 4:16 am

dat is ok
but even if i change d image to some other image still m getting java.lang.IllegalArgumentException error
or "out of bound " , what this error refers to


plz look at my program
only image141.jpg image is working and if i try this program with som other , dan error occurs
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: jar from website

Postby DevelopmentTeam » Mon Oct 29, 2007 4:44 am

Hint: Better use PNG and not jpg

Now the problem you have doesnt look like image problem or memory thing. Do you say just changing the file name alone for the background images gives the problem...
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: jar from website

Postby DevelopmentTeam » Mon Oct 29, 2007 4:45 am

you can also upload the images old and new in your post, so that we can take a look.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: jar from website

Postby rahul7star » Mon Oct 29, 2007 4:48 am

yes , only this image is working , if i try with other image having dimesnsion even less dan d current one ,"Index Out of bound " error occurs , i dont knw y is this happening ,
rahul7star
Regular User
 
Posts: 84
Joined: Fri Aug 17, 2007 11:22 am

Re: jar from website

Postby DevelopmentTeam » Mon Oct 29, 2007 4:55 am

rahul7star wrote:yes , only this image is working , if i try with other image having dimesnsion even less dan d current one ,"Index Out of bound " error occurs , i dont knw y is this happening ,


This error should be showing when you use sprite and point to the wrong frame...

But you are speaking about this error in a blank image... I dont understand why this happens.

Few tips: Dont user layer manager, instead you can directly draw each images on the screen one over the other. Meanwhile layermanager is helpful only when you use a tiled layer. Also I dont understand why you have placed background image in a sprite. Here should be the problem. Just keep it a simple image and draw it on the screen. Keep the position stored in a variable.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Next

Return to J2ME Games

Who is online

Users browsing this forum: No registered users and 1 guest

cron