Hi, I’m using Cocos 3.8x
I’d like to make some endless game by using TMX File.
I want to make some tile change the tile texture when get hit by the player. I’m trying to use setTileGID(GID, coordinate) but nothing change. And when the player hit the tile (setPlayerPosition function hiddenTrap), my draw calls in showFPS become 200++. Anyone can help? I’m trying to removeTileAt with same coordinate and its success with the correct tile.
init: function() {
this.map = new cc.TMXTiledMap(res.map_tmx);
this.tileLayer = this.map.getLayer("Background");
this.obsLayer = this.map.getLayer("Meta");
this.obsLayer.visible = false;
this.addChild(this.map);
this.scheduleUpdate();
},
update: function() {
this.setPlayerPosition();
},
setPlayerPosition: function() {
var botSensor = cc.p(tileCoord.x, Math.floor(tileCoord.y) + 1);
var botTile = this.obsLayer.getTileGIDAt(botSensor);
if (botTile) {
var properties = this.map.getPropertiesForGID(botTile);
if (properties) {
if (properties['Collideable']) {
var tilePos = this.obsLayer.getTileAt(botSensor);
player.setPosition(cc.p(player.getPositionX(), tilePos.y + tilePos.height + tilePos.height / 2));
}
if (properties['hiddenTrap']) {
this.tileLayer.setTileGID(5, botSensor);
}
}
}
},