How to move a bitmap (like long green grass moving by the wind) fixing its pivot at the bottom center point of the bitmap in android? -
in application,i have long green grass bitmap.i have fix bitmap not move bottom part , should placed @ left bottom corner of screen.so have fix pivot @ bottom center of bitmap.after should move bitmap (like grass moving wind) left,some pixels , right,some pixels distance.but bitmap should not move pivot position.i unable fix pivot position , achieve grass moving.i posting code have done.please me solve this.
private float direction = 1; private float mangle = 0; bitmap green_1 = bitmapfactory.decoderesource(getresources(), r.drawable.green_1); private void drawpaper(canvas canvas){ paint paint=new paint(); paint.setantialias(true); paint.setfilterbitmap(true); if (mangle >= 3) { direction=-0.2f; } else if (mangle<=-3) { direction=0.2f; } mangle = mangle + direction; matrix matrix = new matrix(); matrix.posttranslate(0,heightofcanvas-green_1.getheight()); matrix.posttranslate(0, mangle); canvas.drawbitmap(green_1, matrix, paint); }
thanks in advance.
just rotate canvas using :
canvas.rotate(deg, xpivot, ypivot)
Comments
Post a Comment