blackberry - Do screen transitions when the user clicks on a bitmap -


i working on ebook app need transition screens left right , right left. tried many samples i've found, not successful. how change screen when user clicks on screen left right , right left. basic idea transition of pages. went through developer support forum thread "page-flip effect" looking solution, can't see it.

the following code not logical. in position have implement flip effect flipping pages in screen , how implement it?

public class transitionscreen extends fullscreen implements runnable{       private int angle = 0;      bitmap frombmp,tobmp;      public transitionscreen(){      }     public transitionscreen(animatablescreen from,animatablescreen to) {             frombmp = new bitmap(display.getwidth(), display.getheight());            tobmp = new bitmap(display.getwidth(), display.getheight());          graphics fromgraphics =  graphics.create(frombmp);          graphics tographics =  graphics.create(tobmp);           object eventlock = getapplication().geteventlock();           synchronized(eventlock) {                from.drawanimationbitmap(fromgraphics);                to.drawanimationbitmap(tographics);              // interpolate myoffset target               // set animating = false if myoffset = target               invalidate();          }           try {             synchronized (application.geteventlock()) {                 ui.getuiengine().suspendpainting(true);             }          } catch (final exception ex) {          }      }      protected void paint(graphics g){             //control x,y positions of bitmaps in timer task , paint paint go          g.drawbitmap(0,0, 360,                 480, tobmp, 0, 0);         g.drawbitmap(0, 0, 360,                 480, frombmp, 0, 0);      //      invalidate();          }      protected boolean touchevent(touchevent event) {         if (!this.isfocus())             return true;         if (event.getevent() == touchevent.click) {            //      invalidate();         }         return super.touchevent(event);     }  } 

assuming you're working version 5.0 or later of os, page has simple example:

http://docs.blackberry.com/en/developers/deliverables/11958/screen_transitions_detailed_overview_806391_11.jsp

from did code sample posted in question? code not appear close working.

update: can animate transitions simply. assuming know how use timer class, have class-level variable stores current x-position of first bitmap (the variable have value of 0 initially). in each timer tick, subtract amount x-position (however many pixels want move each tick) , call invalidate();.

in each call paint method, then, draw first bitmap using x-position variable call's x parameter, , draw second bitmap using x-position variable plus width of first bitmap. resulting effect see first bitmap slide off left while second slides in right.

a caveat : because java (which means timer events not real-time - they're not guaranteed occur when want them to), animation kind of erratic , unsmooth. best way smooth animation pre-render animation cells (where each progressive combination of 2 bitmaps you're transitioning between), in paint method you're drawing single pre-rendered bitmap.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -