| Reply | « Previous Thread | Next Thread » |
|
hi folks,
my sonyericcson emulator's width:176 and height:220. Im having one image with same height but double the width. so, g.drawImage(transparentImage,0,0,g.TOP|g.LEFT); will display only the first half of the img. when i press any key , i want to show the second hidden part of the same image so that it creates an illusion of moving. when i used, g.translate(-175,0); its suddenly moving to second part but not creates any illusion of movement. before painting transparentImage i ve already painted BGImage. now if i use g.translate(-175,0); g.drawString("painting",8,96,g.TOP|g.LEFT); the "painting " is painted in the BGImage and not on top of transparentImage. Please suggest.... 1. how to move the img gradually 2. how to drawstring on top of that moved img Thanks in advance yafy |
|
Hi,
instead of hardcoding the values for drawing the image just use variables that increases or decreases their values as the key is pressed. thanks Soku |
|
thanks for reply...
i actually used the following code below, for(int i=0;i<-175;i--){ g.translate(i,0); try{ t.sleep(500); }catch(Exception e){} g.drawImage(interfaceImage,i,0,g.TOP|g.LEFT); } but its not working.Am i correct or how can i modify my code... plz suggest. yafy |
|
Hi Yafy,
I think here is a problem in ur code. where have u written the code. does it execute the painting part.ie: does it call the repaint() & serviceRepaints() in the for loop itself ? For every g.translate(i,0); u have to call repaint or servicerepaints() If possible Can u please post the whole sample code Wang |
|
hi
Quote: "For every g.translate(i,0); u have to call repaint or servicerepaints()" thats also not working. Below is my paint : public void paint(Graphics g) { System.out.println("enter into paint....."); int w = g.getClipWidth(); int h = g.getClipHeight(); // wordWrap = new WordWrap(Font.getFont( Font.FACE_PROPORTIONAL, // Font.STYLE_BOLD | Font.STYLE_PLAIN, Font.SIZE_SMALL ),QStr,w); g.setFont( Font.getFont( Font.FACE_PROPORTIONAL, Font.STYLE_BOLD | Font.STYLE_PLAIN, Font.SIZE_SMALL ) ); g.setGrayScale(255); g.drawImage(BackgroundImage,0,0,g.TOP|g.LEFT); g.drawImage(questionBarImage,0,0,g.TOP|g.LEFT); g.setClip(0, 0, interfaceImage.getWidth(), interfaceImage.getHeight()); if(translateFlag == 1 ){ for(int i=0;i<-175;i--){ g.translate(i,0); repaint(); g.drawImage(interfaceImage,i,0,g.TOP|g.LEFT); try{ t.sleep(500); }catch(Exception e){} } g.drawImage(okButtonImage,175,210,g.TOP|g.LEFT); g.drawImage(passButtonImage,315,210,g.TOP|g.LEFT); g.drawString(A1Str,215,86,g.TOP|g.LEFT); g.drawString(A2Str,215,120,g.TOP|g.LEFT); g.drawString(A3Str,215,154,g.TOP|g.LEFT); g.drawString(A4Str,215,188,g.TOP|g.LEFT); translateFlag = 0; }else {} if(playFlag == 1){ playFlag = 0; switch(spinMidlet.randomCategory) { case 1: translateFlag = 1; g.drawImage(interfaceImage,0,0,g.TOP|g.LEFT);//first part of img is painted here correcty g.drawImage(generalImage,75,5,g.TOP|g.LEFT); //after painting generalimg i want to move the translateimg. repaint();break; case 2: .......... } }} else{ g.drawImage(interfaceImage,0,0,g.TOP|g.LEFT); } g.drawImage(playButtonImage,10,210,g.TOP|g.LEFT); }//end paint ro be clear ,when i press play button (playFlag=1) generalimg is painted on interfaceimg and set translateflag =1 .after this only i want to translate(move) interfaceimg . thanks yafy |
|
Hi Yafy,
Please use the paint method only for painting.Please avoid the logic and other non-painting methods from the paint method. Thanks Soku |
|
Hi yafy.
http://www.microjava.com/developer/f...ontent_id=1835 here is a sample wich helps u to scroll an image. Regards, Wang |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Wrap text using drawString ? | artemg | Mobile Java General | 6 | 2009-06-25 11:25 |
| Is pixel by pixel painting possible in standard MIDP? | MobileVisuals | Mobile Java Media (Graphics & Sounds) | 0 | 2006-01-02 20:37 |
| More offscreen DrawString problems !!! (Series 60 J2ME SDK) | cbazza@poliplus.com | Mobile Java Media (Graphics & Sounds) | 0 | 2003-06-13 22:00 |
| Display text on Canvas other than drawString | sengaste | Mobile Java General | 1 | 2003-04-15 12:00 |
| bgcolor is not painting the entire screen | harikrishnag | Browsing and Mark-ups | 1 | 2002-10-21 22:44 |