Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / J2ME / Re: Animation on MIDP 1 on: 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 ...
2  Java Game APIs & Engines / J2ME / Re: Animation on MIDP 1 on: 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
3  Java Game APIs & Engines / J2ME / Animation on MIDP 1 on: 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.
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (31 views)
2014-04-15 18:08:23

BurntPizza (28 views)
2014-04-15 03:46:01

UprightPath (43 views)
2014-04-14 17:39:50

UprightPath (26 views)
2014-04-14 17:35:47

Porlus (43 views)
2014-04-14 15:48:38

tom_mai78101 (64 views)
2014-04-10 04:04:31

BurntPizza (124 views)
2014-04-08 23:06:04

tom_mai78101 (224 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!