Constrain HUD while camera zoom
djmoya
Member Posts: 16
Is there a way to keep the HUD the same size and position while zooming the camera in or out? I tried constraining the width and height to the cameras and the devices screen size but it still doesnt work.
Comments
I have a pause button and Game Score as my HUD that I want to always maintain the same size during gameplay. I have a side scroller game that when a character flies above a certain height the camera zooms out of the scene to reveal more sky and scenery. This shrinks my HUD Buttons and they are hard to see and press.
I believe the solution is to constrain the self.width and self.height to the camera width and height. However my lack of math skills keeps me from figuring out an equation that always maintains the HUD size while the Cam size is moving up and down....?
Also, Im concerned that 5 constraints on each number of my Game Score plus another on my Pause button will slow down performance too much.
I will keep posted.
I know this works for camera movements, but not sure how it works with zooming.
The camera zoom and rotate looks at the scene as a whole, not as a series of layers.
I would think it is totally possible to do with constrains, as a test a while ago, I fixed the rotation of an object whilst rotating the camera. But the maths for that was very very easy, I just rotated the object in the opposite direction to the camera, and the same speed.
look at the end of the intro here
I am using the camera to zoom and rotate to get the effect.
I think, in theory, you could use a similar technique to negate the effects of a zoom, so as the camera zooms in, you zoom out at the same rate the objects you want to remain fixed.
It seems a relatively simple fix for someone with solid math knowledge...I will have to tackle for another day and request it as a feature in the next GS update.
Cheers.
1st. Determine the ratio of your HUD size to your Screen Size: Screen Size Width/Hud Size and Screen Size Height/HUD Size (In my case my HUD is 32x32 So I divided 480/32=15 and 320/32=10)
2nd. Add two Constrain Attributes to you HUD actor.
3rd. In the first Constrain Attribute I put:
Self.Size.Width To: scene.Camera.Size.Width /15
and in the second constrain I put:
Self.Size.Height To: scene.Camera.Size.Height /10
Walla!
However now I need to constrain the position as well as a camera offset to maintain the functionality.
Anyone know of a more elegant fix than adding a bunch of constraints?
There needs to be a way that you can place a graphic on the device screen that is not influenced by the scene Camera....This would be a simple and easy fix! But it seems there is no GS option for that. Just scrollable and non-scrollable....
I just added a suggestion for a zoom option added to the scroll/non-scroll Layers. Please chime in too!
http://gamesalad.com/forums/topic.php?id=21853&replies=1#post-165912
http://i53.tinypic.com/1j8aw5.png
See the small square in the left lower corner - remember its size.
Now look at the second "zoomed" image. You can see the "reset" button actor has increased in size - not good - and there appears to be no fix.
http://i52.tinypic.com/2qdqydf.png
But if you remember the size of the small sqwuare - I can assure you the the original area
( that the the mouse can click on or touch ) is still its original size. It appears the image increased NOT the attribute area.
I have measured this and its true.
So with that in mind maybe there is something we can figure out that will work.