Canvas need Scroll Bar

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

Canvas need Scroll Bar

Postby koey » Sun Jul 15, 2007 9:09 am

Is there any method that I can add scroll bar to a canvas page? or actually, no need the exact scroll bar, but just like the FORM, can turn a page up and down is ok.
thx!
koey
 
Posts: 44
Joined: Fri Jan 19, 2007 5:07 pm

Postby DevelopmentTeam » Sun Jul 15, 2007 11:01 am

There is one simple way to do this. There is no inbuild method to do this. In your canvas if you need to scroll a 176x416 page and lets say your screen is 176x208, Then use a image of 176x416 and draw all the things u need in the image using image.getGraphics and use the graphics object to draw things. Now after drawing everything on to the image now draw the image tot he screen and scroll it (draw different portions of the image using setclip ) when the user presses down button.

Hope this would be simplest way which we usualy use for applications. But when you want a big page like 10 times the size of the screen then this will not work. Or will use a lot of memory.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Postby koey » Sun Jul 15, 2007 12:16 pm

Actually I am using DrawString, (this part of the program is also included in the GamePage.java I sent you before) but as there are too many sentences to display, it cannot be shown in 1 full screen. So, can I use drawImage in this case? I draw my the strings on the image???

Thanks a lot!
koey
 
Posts: 44
Joined: Fri Jan 19, 2007 5:07 pm

Postby DevelopmentTeam » Mon Jul 16, 2007 3:57 am

no... if you are going to draw string on the screen, its much more simple. First split the string into small strings, then draw the array from 0 to 10 at first, then when the user press down key, show 1 to 11 and then again 2 to 12 and goes on. This is very much efficient when us draw scrolling text on screen.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to J2ME Games

Who is online

Users browsing this forum: No registered users and 1 guest

cron