| Reply | « Previous Thread | Next Thread » |
|
hi, does anyone have any idea how to animate a graphic object or text across the screen without having to repainting the background? cos on my paint() method there's a lot of logic happening, and i dont want to call all of them.
|
|
There's no magic involved. If you don't want to repaint the whole background you don't have to, but you do have to repaint the part that was hidden behind the object in the initial frame. So you need to keep track of the objects old position (that's easy), and find a way to just repaint the part that was covered by the object (that can be quite tricky, depending on the game). Another approach can be to save the background (all the objects that don't move and are behind the moving objects) in an image and paint that image instead of redoing all the logic needed to create it.
shmoove |
|
hi..
why dont u try using flags and put all the things that u dont want to repaint in the else() block and only paint that part which u want to animate in the if()block..?? something like...:- public void paint(Graphics g) { if(flag) { animate; } else { dont animate; } } in the non animate part u can specify the clip area as well so that the entire area doesnt have to be repainted. as far as i know there is no other way to animate without calling the paint(). Cheers |
| mayankkedia |
| View Public Profile |
| Find all posts by mayankkedia |
|
u can use "repaint(x,y,w,h);" repaint the area that u want to only.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|