| Reply | « Previous Thread | Next Thread » |
|
Hi,
My problem is i want to scroll a image on canvas class to do that iam using a loop but the problem is the image is coming down at a time instead it must move down slowly,and if iam using threads to control paint method ,repaint is not calling paint.Its urgent if some one has idea regarding it pls helpme. |
|
Hi,
Please check this link http://www.microjava.com/developer/f...ontent_id=1835 Hope this will help you. Thanks Soku |
|
Hi,
But it scroll only background image i want to scroll image on constant backroung. |
|
Hi raj,
Are u referring to a ticker like image scrolling?? U have to draw the image over the background image. Just change the x & y coordinate as u like. It will be better if u use a thread or a timer task. Wang |
|
Hi,
If you want to move an image over a background that doesnt change,then just alter the X & Y co-ordinates of the image and just dont alter the background positions. Thanks Soku |
|
Hi raj_ba03! Welcome to Nokia Discussion Boards!! :)
Here is the code that will work fine for vertical scrolling of an image in the Res folder If you want to make horizontal scroll, change "g.drawImage(image,0,count,Graphics.TOP|Graphics.LEFT);" to g.drawImage(image,count,0,Graphics.TOP|Graphics.LEFT); Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class TestScroll extends MIDlet
{
TestCanvas tc = new TestCanvas();
public void startApp()
{
Display.getDisplay(this).setCurrent(tc);
}
public void pauseApp(){}
public void destroyApp(boolean bl){}
}
class TestCanvas extends Canvas implements Runnable
{
Thread thread;
Image image;
int count;
int imageSplitHeight=10;
public TestCanvas()
{
try
{
image = Image.createImage("/testImg.png");
}catch(Exception e){System.out.println("image not found");}
thread = new Thread(this);
thread.start();
}
public void run()
{
while(true)
{
try
{
count++;
Thread.sleep(100);
repaint();
}catch(Exception e)
{
}
}
}
public void paint(Graphics g)
{
g.setColor(200,200,200);
g.fillRect(0,0,getWidth(),getHeight());
g.drawImage(image,0,count,Graphics.TOP|Graphics.LEFT);
}
}
Regards Gopal Ps: Tested in WTK2.3 Default Emulator. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| HELP: Mutable Image to Immutable Image? | rj_cybersilver | Mobile Java Media (Graphics & Sounds) | 1 | 2005-03-26 10:58 |
| PNG Image won't load | maaberge | Mobile Java General | 1 | 2003-11-16 19:13 |
| Major problem with delegation to Canvas | bartekn | Mobile Java Media (Graphics & Sounds) | 8 | 2003-10-08 18:46 |
| Image Menu with canvas | efeba | Mobile Java Media (Graphics & Sounds) | 2 | 2003-06-26 12:33 |
| Managing PNG image Size | ramka001 | Mobile Java General | 2 | 2003-05-21 18:54 |