java - canvas bitmap animations without using a sprite sheet -
bitmap[] planeframes = new bitmap[4]; protected void ondraw(canvas canvas) { for(int = 0 ; < planeframes.length;i++) canvas.drawbitmap(planeframes[i], plane.getcenterx(), 0, null); // planeframes array of bitmaps }
im trying animate plane swapping images not working don't know if method simple work with
you can not animate way. ondraw
called per draw iteration meaning whatever draw on canvas @ return what's going drawn on screen. you're doing here drawing bitmaps on canvas @ same spot , plastered on top of each other.
what need call invalidate() method of view. make things more efficient, can use rect
or define areas around bitmaps.
@override protected void ondraw(canvas canvas) { canvas.drawbitmap(planeframes[i], plane.getcenterx(), 0, null); if(++i >= planeframes.length) { = 0; } invalidate(bmprect); }
this consistently draw through bitmaps while repeatedly drawing new bitmaps. last forever long view on screen. bmprect
rect has coordinates of bitmap.
Comments
Post a Comment