0
我使用瓷磚的地圖,地圖TMX如何 檢查碰撞折線() 。我檢查碰撞sucuess發展中andEngine遊戲。但折線,我不知道碰撞。 可以幫助我。AndEngine:處理衝突折線TMX地圖
是map.tmx:
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="15" height="15" tilewidth="32" tileheight="32" nextobjectid="13">
<tileset firstgid="1" name="images" tilewidth="32" tileheight="32">
<image source="images.png" width="512" height="384"/>
</tileset>
<layer name="Tile Layer 1" width="15" height="15">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAC2NiYGBgGsWjeBQPGAYASiKnxoQDAAA=
</data>
</layer>
<layer name="Tile Layer 2" width="15" height="15">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAC2NgGFggCsRiSPzVQLwGjzwyUAViNST+biDeg0eeXqAQiIvIkAOBRiBuIkOOlqAUiMuQ+Ohx5ArEbjj0tgJxGxIfPY5CgTiMCm7EBqSBmAcHlqGRneQAAE0g83SEAwAA
</data>
</layer>
<objectgroup name="Object Layer 1" width="15" height="15">
<properties>
<property name="wall" value="true"/>
</properties>
<object id="1" x="69" y="68" width="54" height="50"/>
<object id="2" x="326" y="69" width="53" height="49"/>
<object id="3" x="328" y="293" width="50" height="48"/>
<object id="4" x="70" y="293" width="53" height="48"/>
<object id="5" x="111" y="392" width="228" height="15"/>
<object id="8" x="69" y="199" width="49" height="50"/>
<object id="12" x="192" y="127">
<polyline points="0,0 61,125 179,112 230,149"/>
</object>
</objectgroup>
</map>
// --------------------碰撞---------- -----------
private void createUnwalkableObjects(TMXTiledMap map){
// Loop through the object groups
for(final TMXObjectGroup group: this.mTMXTiledMap.getTMXObjectGroups()) {
if(group.getTMXObjectGroupProperties().containsTMXProperty("wall", "true")){
// This is our "wall" layer. Create the boxes from it
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);
}
}
}
}