WitheringTreant Posted December 14, 2014 Share Posted December 14, 2014 Hey, I've recently made a group to contain parts of the player's tank, including a turret. I noticed that turret.x and turret.y are not returned as gameworld coordinates, but coordinates relative to the group position.In this case, turret.x = 20 and turret.y = 40, and the returned values are not affected by group rotation or group position. Basically, I need to get the gameworld X and Y position of the turret, when group rotation is taken into account. That way I could reset the bullet on top of the turret when it's firing. Group rotation needs to be taken into account because the tank can rotate, thus changing the turret positioning around the group's center (pivot). // This is how i first create the group and then the turret as it's childplayer_tank_group = game.add.group();player_tank_group.x = 500;player_tank_group.y = 500;player_tank_group.create(20, 40, 'turret_medium_yellow'); //parts are added as coordinates relative to the group positionturret = player_tank_group.getAt(0); // then rotate the groupplayer_tank_group.rotation = 1; // then i need to get these 2 values, reflecting group rotation and game world position.turret.x in gameworld coordinatesturret.y in gameworld coordinates Does anyone have any idea how to achieve this? I need this and i've been stuck for a while with it. Link to comment Share on other sites More sharing options...
WitheringTreant Posted December 15, 2014 Author Share Posted December 15, 2014 Bump. I clarified the topic post. Let's hope someone has any ideas.. Link to comment Share on other sites More sharing options...
WitheringTreant Posted December 15, 2014 Author Share Posted December 15, 2014 Hmm ok seems like I solved it. var point = turret.world; bullet.reset(point.x, point.y); Link to comment Share on other sites More sharing options...
Recommended Posts