Search the Community
Showing results for tags 'givemeabreakpixi'.
-
var MapObjects = {}; function setupMapObjects() { MapObjects.chest = new PIXI.Sprite(frame("images/chest.png", 0, 0, 50, 50)); MapObjects.chest.x = 200; MapObjects.chest.y = 200; MapObjects.chest.anchor.x = 0.5; MapObjects.chest.anchor.y = 0.7; MapObjects.chest.interactive = true; MapObjects.chest.on('click', openChest); MapObjects.chest.hitArea = new PIXI.Circle(MapObjects.chest.x, MapObjects.chest.y, 10); MapObjectsArray.push(MapObjects.chest); stage.addChild(MapObjects.chest); }; function openChest() { console.log('open'); }; var Player = {}; function setupPlayer(){ Player.sprite = new PIXI.Sprite(frame("images/Player.png", 0, 0, 128, 128)); Player.sprite.anchor.x = 0.5; Player.sprite.anchor.y = 0.7; Player.sprite.x = 150; Player.sprite.y = 150; Player.vx = 0; Player.vy = 0; Player.direction; Player.directionIdle; Player.idle; Player.moving; Player.frameCycle = 0; Player.action = false; Player.run = false; Player.melee = false; Player.sprite.interactive = true; Player.sprite.on('click', openChest); stage.addChild(Player.sprite); }; MapObjects.chest does not respond to the .on('click', openChest) but Player.sprite does. I don't know man.... I just don't know. I marked this off my To Do list a few days ago cause it was working but now... (head explodes) I guess I should ask if there is another way to apply the click event to the sprite.