Hey guys, I was able to make my character move using Tilemap Character's behaviour and now I'm trying to achieve the same using click event.
However, I'm gettin' some weird positions on click as well as not corresponding X and Y, only one of each per click, example, if I click Tile { x: 4, y: 8 } the character will move to x:4 but not to y:8 on the first time I click it. I'm using setDestination, any ideas on what could be wrong? Here's my piece of code for that:
// Map Settings
var mapTileSettings = { numTiles:{x:18, y:15}, tileSize:{x:72, y:72 }};
var mapSettings = createGameMap();
wade.tilemap.init(mapTileSettings);
wade.tilemap.setTiles(mapSettings.myMap, mapSettings.tileTemplates);
// Player Movement
this.onClick = function(eventData){
var clickPos = eventData.screenPosition;
var player = wade.getObjectByName(gameMaster).getBehavior();
var tilePos = wade.tilemap.getTileCoordinates(clickPos.x, clickPos.y);
player.clearDestinations();
player.setDestination({x:tilePos.x, y:tilePos.y});
}
// Player Definition
var sprite = new Sprite();
// sprite.setSize(0.10, 0.14);
sprite.setLayer(2); // Using layer 2 because I have a fixed text (follow camera) in layer 1
var playerObj = new SceneObject(sprite);
playerObj.setName(gameMaster);
// Tilemap behavior
var behavior = playerObj.addBehavior(TilemapCharacter);
behavior.maxPathLength = 200;
behavior.rotationOffset = 1;
behavior.allowDiagonal = false;
behavior.movementSpeed = 200;
behavior.automaticRotations = false;
behavior.drawCollisionBox = false;
behavior.animations.walk_n = "walkUp";
behavior.animations.walk_s = "walkDown";
behavior.animations.walk_e = "walkRight";
behavior.animations.walk_w = "walkLeft";
wade.addSceneObject(playerObj, true);
Any ideas on why am I gettin' these wrong weird position on player.setDestination({x:tilePos.x, y:tilePos.y}); function?
Thanks in advance!