Abderrahmane TJ Posted February 3, 2015 Share Posted February 3, 2015 Hi, I have a group, to which I add a sprite upon Mouse Click on the game. In the callback attached to the event I want to get the group bounds. The problem is, the group does not update its bounds correctly. At the moment the click happens, the bounds get some strange values that do not match the real bounds I am looking for. It's only after a short while, do the bounds actually get the right values it should update to. Here is a sample code in which this behavior occur. The console shows info about the Group before click, right after the click, and after a timeout :http://jsbin.com/kinaxa/1/edit?js,console,output Link to comment Share on other sites More sharing options...
Abderrahmane TJ Posted February 14, 2015 Author Share Posted February 14, 2015 bump Link to comment Share on other sites More sharing options...
hollowdoor Posted February 15, 2015 Share Posted February 15, 2015 Maybe instead of getBounds you should use getLocalBounds. I couldn't explain why getBounds doesn't work because I'm not that familiar with Phaser, but getLocalBounds is at least consistent. Abderrahmane TJ 1 Link to comment Share on other sites More sharing options...
Abderrahmane TJ Posted February 15, 2015 Author Share Posted February 15, 2015 getLocalBounds seems to be the right way to go about it. but I am curious to know why the other one does not work, and what's the difference between the two Link to comment Share on other sites More sharing options...
hollowdoor Posted February 15, 2015 Share Posted February 15, 2015 In the docs getBounds says it takes the world into account. Which doesn't really say anything because the result is the same as getLocalBounds at least some of the time. Link to comment Share on other sites More sharing options...
Recommended Posts