pranadevil Posted January 2, 2015 Share Posted January 2, 2015 hi buddies, i want to know if there is a way to know the exact x and y coordinates of each item in a group. i want to know the heigth of a falling item of a group and do something depending on it. for example change its velocity in y. any ideas will be great thanks in advance happu new year to all of you guys!!! Link to comment Share on other sites More sharing options...
spencerTL Posted January 2, 2015 Share Posted January 2, 2015 The x and y of a sprite are relative to its group. You can find the x or y world coordinates by using sprite.world.x; (or y). You can use whatever relevant group function you need to go eg. group.forEachAlive() through the items and take the action you want depending if it meets a certain condition. These functions pass the item as the first parameter to the callback that you set. Is this what you meant? pranadevil 1 Link to comment Share on other sites More sharing options...
pranadevil Posted January 2, 2015 Author Share Posted January 2, 2015 ok im gonna explain it more detailed, imagine a item of a group of two falling, i want to check when it collides to a static block (with no gravity and no y,x velocity). then when the item is above of my static block i want to modify its parameters, give the falling item velocity in x. i tried with game.physics.arcade.collide(falling,static); but it seems not to work to my objetive, cause there is a button to accelerate the falling item, and it affects it before it touches the static block. so i wonder if i can check the x, y coordinates of the falling item and realize when it is above the other item, then the callback fuction of the button could take actions, not before. thanks in advance. Link to comment Share on other sites More sharing options...
pranadevil Posted January 2, 2015 Author Share Posted January 2, 2015 spencerTL you rock, thanks for the code! Link to comment Share on other sites More sharing options...
Massemassimo Posted January 3, 2015 Share Posted January 3, 2015 Would you mind setting spencerTLs answer as the "best answer" so everyone can see the solution at a glance? Or did he send you code as a PM? Link to comment Share on other sites More sharing options...
Recommended Posts