collision - Andengine Tiledmap How to make sprites impassable by another? -
i have working collision system sprites dont want "player" pass. problem have no idea should execute on collision make player not pass sprites.
wallcollision() method empty.
if(tmxtileproperties.containstmxproperty("collision", "1")) { rectangle rect = new rectangle(tmxtile.gettilex(), tmxtile.gettiley() ,128, 128, mengine.getvertexbufferobjectmanager()) { @override protected void onmanagedupdate(float psecondselapsed) { if (player.collideswith(this)) { wallcollision(); } } }; rect.setvisible(false); mainscene.attachchild(rect); }
the question located here addresses this. method below creates jbox2d body @ same position blocked tile. i'm not sure how works in conjunction pathfinding exclude blocked tiles, i've seen same approach used in other places, assuming you're using gles2. hope helps.
private void createunwalkableobjects(tmxtiledmap map){ // loop through object groups for(final tmxobjectgroup group: this.mtmxtiledmap.gettmxobjectgroups()) { if(group.gettmxobjectgroupproperties().containstmxproperty("wall", "true")){ // our "wall" layer. create boxes for(final tmxobject object : group.gettmxobjects()) { final rectangle rect = new rectangle(object.getx(), object.gety(),object.getwidth(), object.getheight()); final fixturedef boxfixturedef = physicsfactory.createfixturedef(0, 0, 1f); physicsfactory.createboxbody(this.mphysicsworld, rect, bodytype.staticbody, boxfixturedef); rect.setvisible(false); mscene.attachchild(rect); } } } }
Comments
Post a Comment