Thursday 15 April 2010

Android - Draw an inverted circle that moves along with the player -



Android - Draw an inverted circle that moves along with the player -

i building android game ball controlled , moved using motion sensor.

there posts on how draw inverted circle like one, unusable android not back upwards bufferedimage.

i created player using codes below

public class player extends task { private final static float max_speed = 20; private final static float size = 16; private circle _cir = null; private paint _paint = new paint(); private vec _vec = new vec(); private vec _sensorvec = new vec(); public player(){ _cir = new circle( 15, 15, size ); //15,15 initial x,y coordinates } public final circle getpt(){ homecoming _cir; } private void setvec(){ float x = -acsensor.inst().getx()*2; float y = acsensor.inst().gety()*2; _sensorvec._x = x < 0 ? -x*x : x*x; _sensorvec._y = y < 0 ? -y*y : y*y; _sensorvec.setlengthcap(max_speed); _vec.blend( _sensorvec, 0.05f ); } private void move(){ _cir._x += _vec._x; _cir._y += _vec._y; } @override public boolean onupdate(){ setvec(); move(); homecoming true; } @override public void ondraw( canvas c ){ c.drawcircle(_cir._x, _cir._y, _cir._r, _paint); } }

question is, how create inverted circle around player player sees limited distance while outer part filled black color? example, this.

android android-canvas circle shadow invert

No comments:

Post a Comment