diffrence of move function speed on devices
Hi
please look this code , when i run it on nokia N97 it`s run very slow but i test it on samsung corby it`s run true , i think if i use game canvas problem be sloved . what should i do to solve this problem .
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.IOException;
import javax.microedition.lcdui.*;
/**
* @author mahdi
*/
public class MIDPCanvas extends Canvas implements Runnable {
Graphics g;
Image img;
int x = getWidth() / 2;
Display display;
public MIDPCanvas(Display display) {
this.display = display;
try {
img = Image.createImage("/pic.jpg");
} catch (IOException ex) {
ex.printStackTrace();
}
}
protected void paint(Graphics g) {
g.drawImage(img, x, getHeight() / 2, Graphics.VCENTER | Graphics.HCENTER);
display.callSerially(this);
}
public void run() {
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
x--;
repaint();
}
}
its run on wtk very fast but in other emulator like LG or nokia its slow
thanks
mahdi68
Junior Poster in Training
95 posts since Jun 2009
Reputation Points: 6
Solved Threads: 0
as already pointed out by adams you are refreshing your graphic to much (actually 100 times per second). You should do it something about 15-20 times per second, but may be even less...
Do not relay on emulator as hat is using your processor and it will much faster then real device
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902