android - How do I get the scene update handler to break when the action is up (AndEngine)? -
i'm trying increase scale of sprite using update handler. doesn't, however, allow scene action event called, sprite continues increasing in size. how update handler break when action up? have:
the update handler:
scene.registerupdatehandler(new iupdatehandler() { @override public void reset() { } @override public void onupdate(float psecondselapsed) { if(fillernum>-1){ if(filler[fillernum].active){ mphysicsworld.unregisterphysicsconnector(mphysicsworld.getphysicsconnectormanager().findphysicsconnectorbyshape(filler[fillernum].sprite)); mphysicsworld.destroybody(filler[fillernum].body); filler[fillernum].sprite.setscale(filler[fillernum].scale+=psecondselapsed*3); filler[fillernum].body = physicsfactory.createcirclebody(mphysicsworld, filler[fillernum].sprite, bodytype.dynamicbody, fixture_def); mphysicsworld.registerphysicsconnector(new physicsconnector(filler[fillernum].sprite, filler[fillernum].body, true, true)); } } } });
and scene touch event:
@override public boolean onscenetouchevent(scene pscene, touchevent pscenetouchevent) { if(this.mphysicsworld != null) { if(pscenetouchevent.isactiondown()) { createfiller(pscenetouchevent.getx(), pscenetouchevent.gety()); return true; } if(pscenetouchevent.isactionup()){ log.e("action up", boolean.tostring(filler[fillernum].active)); createstationaryfiller(); } } return false; }
just save instance of updatehandler:
handler = new iupdatehandler() {... etc
and when want stop it, call scene.unregisterupdatehandler(handler)
Comments
Post a Comment