android - Collision Detection with Alpha in Box2D for AndEngine -
i creating first game in andengine (gles 2) , using box2d physics.
the collision detection works doesn't seem take account alpha values on png files (i think happening) collision happens way before 2 sprites touch. don't need collision pixel perfect reasonably accurate.
this how set collision detection:
final charactersprite charactersprite = new charactersprite(camera_width/2, camera_height/2, this.mcharactertextureregion, this.getvertexbufferobjectmanager()); mphysicsworld = new fixedstepphysicsworld(60, new vector2(0, 0), false); scene.registerupdatehandler(mphysicsworld); playerbody = physicsfactory.createboxbody(mphysicsworld, charactersprite, bodytype.dynamicbody, physicsfactory.createfixturedef(0, 0, 0)); playerbody.setuserdata("player"); charactersprite.setbody(playerbody); mphysicsworld.registerphysicsconnector(new physicsconnector(charactersprite, playerbody, true, true)); mphysicsworld.setcontactlistener(createcontactlistener()); attachsprites(scene); thank you
well use shape other box (circle might choice) or use custom sized box doesn't go way around sprite. if want more precision go polygon or multiple polygons.
Comments
Post a Comment