Jump to content

know the exact x and y coordinates of each item of a group


pranadevil
 Share

Recommended Posts

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 :lol:

 

happu new year to all of you guys!!!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...