How to keep HUD in same place when camera rotates
firedream79
Member Posts: 8
I am working on a running platform game and I would like to add some rotating scene and I have some problem: I would like to apply a score and buttons controls, but when rotate the camera I can't maintain the initial position.
I fixed the angle using: self.rotation = -camera.rotation but it can't help me to maintain the initial position.
I tried to use:
self.position.x = game.sceneX-magnitude( self.offsetX , self.offsetY )*sin(( self.Rotation )-atan( self.offsetX / self.offsetY ))
self.position.y = game.sceneY+magnitude( self.offsetX , self.offsetY )*cos(( self.Rotation )-atan( self.offsetX / self.offsetY ))
but It doesn't solve the problem.
Could somebody help me?
I fixed the angle using: self.rotation = -camera.rotation but it can't help me to maintain the initial position.
I tried to use:
self.position.x = game.sceneX-magnitude( self.offsetX , self.offsetY )*sin(( self.Rotation )-atan( self.offsetX / self.offsetY ))
self.position.y = game.sceneY+magnitude( self.offsetX , self.offsetY )*cos(( self.Rotation )-atan( self.offsetX / self.offsetY ))
but It doesn't solve the problem.
Could somebody help me?
Comments
im not sure sorry but maybe you could try this, no harm in giving it a go
GSINVENTION FREE TEMPLATES
in your HUD button it is constrained y 100 and lets say the screen rotates 100 degrees to the right then you constrain it to y 200. you can probably do this after using attributes and more, but i never use screen rotate so its hard for me, maybe @Socks knows?
GSINVENTION FREE TEMPLATES
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
I constrained my actor defining start (x,y) and end position.
The problem is that even if I have been very carefull I can't avoid micromovements...
For this reason I am looking for some better solution...
GSINVENTION FREE TEMPLATES
this will keep it from a certain distance away from your main character (the 235)
at a certain angle (the 142)
i use 142 to keep HUD in upper left corner and 33 for upper left corner
both have to be the same numbers
this needs to be on a scrolable scene.
constrain attribute
-consttrain: self.rotation to scene.camera.rotation
constrain attribute
-constrain : self.position.x to (scene.hero.hero.position.x)+235*cos(scene.camera.rotation)+142
constrain attribute
-constrain : self.position.y to (scene.hero.hero.position.y)+235*cos(scene.camera.rotation)+142
ACTOR 1 and ACTOR 2 (235,235).
I rotate camera wtih an angle 235, but ACTOR 2 doesn't keep the start position...
actor2.x = scene.Background.Actor 1.Position.X +235*cos( scene.Camera.Rotation )+142
actor2.y = scene.Background.Actor 1.Position.Y +235*cos( scene.Camera.Rotation )+142
maybe I am doing some mistakes?
I am trying to keep fixed the score in the upper left corner when the camera rotate +10, but it seems impossible on GS.
Could somebody help me?
http://www.deepblueapps.com/helicopter-hud-template/
Another way would be like you mentioned using cos and sin like our rolling bones (playable link below).
Quick piece of advice if your having a pause button in the top right for e.g. and your going the cos sin route you will need a fake pause button (alpha 0 or graphics off) on a layer with scrollable unchecked for it to register a touch.
http://www.deepblueapps.com/rolling-bones/
Darren.
I