Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Animation on MIDP 1  (Read 1739 times)
0 Members and 1 Guest are viewing this topic.
Offline paco_rjp

Junior Newbie




Java games rock!


« Posted 2004-04-20 00:09:06 »

I'm tried to animate a PNG image using sample code that comes with the Nokia Development Suite(Helicopter). The PNG image I used consists of 7 frames of different actions the image will do. I understand the idea of the sample code to animate an image, I used my PNG image on it. It did animate but the problem is the animation is not what i expected, the frames seems to overlap each other. Can anyone suggest another sample code for animation and can you direct me to a resource about threading in J2ME? I also want to create a custom UI for a game I'm trying to do.
Offline shmoove

Junior Member




Doh!


« Reply #1 - Posted 2004-04-20 00:17:25 »

Quote

the frames seems to overlap each other

They probably are a different size from the helicopter images.
Quote

I also want to create a custom UI for a game I'm trying to do?

That's not exactly a question.

shmoove
Offline paco_rjp

Junior Newbie




Java games rock!


« Reply #2 - Posted 2004-04-20 00:36:17 »

Quote

They probably are a different size from the helicopter images.
That's not exactly a question.

shmoove

The images are of the sames size, the difference is that my image is a robot.

yah, your right its not a question, i'll just edit it...thanks
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline mrmx

Senior Newbie




Java may rule world of bits...


« Reply #3 - Posted 2004-04-21 21:20:58 »

Hi!

Seems that your code did not cleared the previous frame area, thus the operlapping of them all.

If you show your animation code will be more easy.

Also you can check this animation code: http://www.jtgl.org/modules/mylinks/visit.php?cid=12&lid=14

Greetings

Manuel Polo.
Offline paco_rjp

Junior Newbie




Java games rock!


« Reply #4 - Posted 2004-04-22 01:07:27 »

like in my initial post, I am modified the Helicopter sample code that comes with nokia development suite. I just removed the lines that would draw the background. That leaves me with the helicopter itself then i changed the image that was called and just increased the number of frames.

Here is the whole robot class.

import javax.microedition.lcdui.*;
import java.io.*;


public class Robot
{
 private static Image[] myImage;
 private static int x, y;
 private static int frame=4;

 private static int imageWidth, imageHeight;

 private final String CHARACTER_NAME="proto01";
 private final String imgFiller="/filler.png";
 private Image imgFill;
 private Image[] imgCharacterStrip;
 private final int CHARACTER_FRAMES=14;
 private Image[] imgCharacter=new Image[CHARACTER_FRAMES];
 private int clipAreas[][];

 public Robot()
 {
   // load the images from the .jar
   imgCharacterStrip=getImages(CHARACTER_NAME,1);
   try {
     imgFill = Image.createImage(imgFiller);
   }
   catch (IOException ex) {
   }
   // all character frame images are assumed
   // to be the same height and width
   imageWidth=imgCharacterStrip[0].getWidth()/CHARACTER_FRAMES;
   imageHeight=imgCharacterStrip[0].getHeight();

   // set the intial position of the character.

   x=(Try1Canvas.getCanvasWidth()/2)-(imageWidth/2);
   y=(Try1Canvas.getCanvasHeight()/2)-(imageHeight/2);

 }

 public void setFrame()
 {
   if(++frame>=CHARACTER_FRAMES)
   {
     frame=7;
   }
 }

 public void draw(Graphics g)
 {
   if(imgCharacterStrip[0]!=null)
   {
     g.setClip(x,y,imageWidth,imageHeight);
     //g.drawImage(imgFill,0,y,g.LEFT |g.TOP );
     g.drawImage(imgCharacterStrip[0],x-(imageWidth*frame),y,g.LEFT | g.TOP);
     //g.setClip(0,0,32,47);
     g.setClip(0,0,Try1Canvas.getCanvasWidth(),Try1Canvas.getCanvasHeight());
     
   }
 }
 public void draw2(Graphics g){
   g.setClip(0,0,Try1Canvas.getCanvasWidth(),Try1Canvas.getCanvasHeight());
   g.drawImage(imgFill,0,y,g.LEFT |g.TOP );
 }
 private Image[] getImages(String imgName, int frames)
 {
   return Try1.getImages(imgName, frames);
 }
}


hope you can help a newbie ...
Offline shmoove

Junior Member




Doh!


« Reply #5 - Posted 2004-04-22 08:52:11 »

You say you have 7 frames. So why is CHARACTER_FRAMES equal to 14. And in setFrame() you set the initial frame to 7?
Those are the things I find strange.

shmoove
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (20 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!