Search the Community
Showing results for tags 'callbacks'.
-
Hey guys I'm trying to get a function to be called each time the gamepad is released. I think I need to use the function addCallbacks() and the property onUpCallback from the Gamepad class. I have Gamepad called pad1 and a function test() that should be called every time any gamepad button is released, but not really sure how callbacks work/correct syntax. Thanks for your help.
-
Hello, i was trying to attach eventListeners to sprites. I did that in the create function : this.selectorGroup = game.add.group();height = 200;// looping through json for(var key in res){ var selector = game.add.sprite(625, height - 10, "resourceSelector"); selector.inputEnabled = true; // adding some custom property selector.data = key; // attaching eventListener selector.events.onInputUp.add(this.triggerSearch); // adding the sprite to a group this.selectorGroup.add(selector); height = height+40;}// setting all elems of the group to alpha 0this.selectorGroup.alpha = 0;then in the callback function : triggerSearch = function (item, pointer) { // this is working console.log("looking for ", item.data); // hide previous selections this.selectorGroup.alpha = 0; // this isnt working item.alpha = 1;};also, i cant access the selectorGroup to apply alpha 0 to all children in order to reset previous selections. though, if i dont set alpha to 0 to sprites in create function and i put item.alpha = 0 in the callback, i can remove opacity from the sprites... Am i missing something?
-
#1 are tilemaplocationcallbacks working in 1.2 ? # is it (will it be) possible to assign materials and collisioncallbacks to layers so i can put all my "ice" tiles in one layer (friction=0) and all my "lava" tiles in another (player.kill()) ? (or what would be the appropriate way to accomplish those things?) thank you all in advance !!
-
Hey all I've used the Prototype pattern explained here and in various forum posts: http://examples.phaser.io/_site/view_full.html?d=sprites&f=extending+sprite+demo+1.js&t=extending%20sprite%20demo%201 This works if I maintain a reference to an object. For example: var player = new FooBar.Player(this.game, x, y); I can then call the functions that I've written in the FooBar.Player class that is an extension of the Phaser.Sprite class. However, I can't access those functions if I use group callback functions: playerGroup.foreach(function(player){ player.somethingCustom(); }; => TypeError: Object [object Object] has no method 'somethingCustom' Is there a way to extend a sprite, add it to a group and maintain its classiness?