proyb2 Posted January 23, 2015 Share Posted January 23, 2015 How do I change the frame to 1 for o2 when it's being overlapped by o1? The current code o2.frame=1 is not working and how to reset the frame to 0 once the rect is not overlap?for(var i=6;i>0;i--){ n1=gobj.add.sprite(i*50,150,hunote,rhunote) gobj.physics.arcade.enable(n1)}function update() { gobj.physics.arcade.overlap(rect, n1, overlapHandler, null, this)}function overlapHandler(o1, o2){...}And the Phaser example explained how to handle 2 sprites, how will it detect and update 6's n1 sprites? Link to comment Share on other sites More sharing options...
mrdotb Posted January 23, 2015 Share Posted January 23, 2015 Hi,You need to use group.Try something like this.function create(){ //Create o1 group o1 = game.add.group(); //make some loop here o1.create(1 * 50, 150, 'spritewith2frame'); o1.create(2 * 50, 150, 'spritewith2frame'); o1.create(3 * 50, 150, 'spritewith2frame'); game.physics.enable(this.o1); //Create o2 group o2 = game.add.group(); //make some loop here o2.create(1 * 50, 150, 'spritewith2frame'); o2.create(2 * 50, 150, 'spritewith2frame'); o2.create(3 * 50, 150, 'spritewith2frame'); game.physics.enable(this.o2);}function update(){ game.physics.arcade.overlap(o1,o2, function(o1,o2){ if (o1.frame == 0){ o1.frame = 1: } });} Link to comment Share on other sites More sharing options...
Recommended Posts