kiwi Posted October 21, 2015 Share Posted October 21, 2015 Hi all, I'm developing a game with a scrolling background.I'm creating a series of houses (each house is a sprite randomly generate which are moved horizontally) with a chimney on top so I created a group and added each house in it. I'm trying to drop an object from the sky and detect if this object hits the chimney (only the chimney, not the roof). As far as I understood I need to separate chimney and house making the object I drop and the chimney "hittable". But, is correct to create a group (with all houses in it) with many groups in it (house + chimney) and detect the hitbox on the chimney? Is this the correct way to do it? Should I try a different approach? thanks Link to comment Share on other sites More sharing options...
Skeptron Posted October 21, 2015 Share Posted October 21, 2015 First, you should add the chimneys as children of the houses. Sprites can have children (like a group), and that's very handy because if chimney is a child of house, then when you move your house chimney will move with it. And you manage just one object, House (which has children like chimney, but you could add windows, doors etc.) Then, I think I would put all the chimneys into a group for collision check. So in the end, you need just one group. Link to comment Share on other sites More sharing options...
drhayes Posted October 21, 2015 Share Posted October 21, 2015 Skeptron is right: stick all those chimneys in a group and check collision against that. And then post a link to your Christmas game for us to play. ( = I bet if you add the chimneys to a group they won't be children of the house sprites anymore. But I also don't think that'll matter. Link to comment Share on other sites More sharing options...
Skeptron Posted October 21, 2015 Share Posted October 21, 2015 Oh you think so? So children of sprites are really into a group I guess. And an object can never be into 2 groups at the same time. Damn. Link to comment Share on other sites More sharing options...
drhayes Posted October 21, 2015 Share Posted October 21, 2015 Yeah. Phaser.Sprite having children is the same thing as Phaser.Group having children. It's how the scene graph gets built, as a composite. Skeptron 1 Link to comment Share on other sites More sharing options...
Recommended Posts