Scaling Camera to make zoom, how do I stop the Non scrolling/HUD items zooming?

StormyStudioStormyStudio United KingdomMember Posts: 3,989
edited November -1 in Working with GS (Mac)
Good evening.

Ok, I have a point where I have the camera in my game scale to half its original size on the x and y, to create a zoom effect. It works really well, except my Menu items/buttons which are also on the screen at the same time scale with the camera even though they are non scrolling layers.

Whats the best way to combat this?

Do I have to scale each of the other items to compensate the camera scale?, will this screw with their positions as it zooms, so do I need to take into account some sort of offset, or is it fine as they're non scrolling items.

Any one come across and solved this problem?

You can see what I'm talking about at 57 seconds, in the below video, my tool box button is scaling up when ideally it would not...(also affects the rest of the menu when its rolled out).

See it at 57 seconds in:

Comments

  • UtopianGamesUtopianGames Member Posts: 5,692
    I'm not sure you can stop them zooming, it doesn't appear to be going off from the view so maybe try using interpolate width and height to compensate for the xs2 camera?

    Shame you can't select affected layers when using something like the camera zoom.

    Darren.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    This is the hardest thing about zooming in and out. In fact in my Angry Zombie Launch I just gave up on it. I have it set up so that the hud buttons are only active and visible when you aren't zoomed out (i.e. when camera width and height are the standard sizes). If you are set on doing it you will need to use the demo by Orbz on global camera coordinates or something. Basically you take your zoomed camera width and devide it by 480 (for iPhone) and constrain this ration to a real game attribute (this is your zoom ratio). Then you need to constrain the width and height of each HUD item to this times the "natural" size. Then you also need to constrain each items X and Y. For this you use that ratio again. So in other words A BUT LOAD OF CONSTRAINS!!!!!

    I really wish GS would fix the way zooming works. It is such a pain!

    EDIT: After you do all that it still won't work because the touch zone does not follow the actor. So I had to create a touch1 actor that constrains to touch1 X and Y with the ratio and the camera origin offset and check if this is overlapping and touch count >0 instead of touch is pressed. SUCKS!
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    scitunes said:
    This is the hardest thing about zooming in and out. In fact in my Angry Zombie Launch I just gave up on it. I have it set up so that the hud buttons are only active and visible when you aren't zoomed out (i.e. when camera width and height are the standard sizes). If you are set on doing it you will need to use the demo by Orbz on global camera coordinates or something. Basically you take your zoomed camera width and devide it by 480 (for iPhone) and constrain this ration to a real game attribute (this is your zoom ratio). Then you need to constrain the width and height of each HUD item to this times the "natural" size. Then you also need to constrain each items X and Y. For this you use that ratio again. So in other words A BUT LOAD OF CONSTRAINS!!!!!

    I really wish GS would fix the way zooming works. It is such a pain!

    That would probably be your best bet. When u zoom in just change the alpha to zero on anything you dont want to zoom. Or interpolate the size
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    thanks for the replies...

    Changing the alpha, or animating the items off screen seems like the best bet then.

    Thanks for the reply,

    and as SciTunes says I hope GS sort this out in the future, as the ability to zoom is such a nice one.
  • JelJel Member Posts: 319
    I was trying to work out the same thing regarding scaling non scrolling actors while zooming and in fact it was kind of simple.

    Create two Game Atts (CameraH and CameraW) for example and constrain them to the camera size in the scene. Then constrain each actor in the scene that needs scaling to the Global Att and divide it by X ( game.cameraH / 3 ) for example.

    The bit I struggling with at the moment as I haven't had much time to think about it (never have kids). Is how constrain their position on the screen relative to the camera zoom?
  • ChunkypixelsChunkypixels Member Posts: 1,114
    Yup... Im not sure you can do it without doing lots of complicated maths stuff and constraints...

    I played with various methods for the zoom in Mole in a Hole, and opted for turning the HUD elements transparent when the zoom kicked in. It looks ok... but not the most ideal situation.

    Like Darren said, would be good if we could have more control of layers regarding zoom/camera controls etc....
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    Yep...went for the transparent option too...

    I want to avoid as many constraint behaviors as possible...
  • ORBZORBZ Member Posts: 1,304
    It's not that hard.

    you can use width or height for computing the zoomFactor, i used width, I'm assuming your camera maintains aspect ratio and the width and height don't stretch the image.

    Constrain zoomFactor = cameraWidth / displayWidth
    Constrain HUDObject.width = desiredWidth * zoomFactor
    Constrain HUDObject.height = desiredHeight * zoomFactor

    Bingo, done.

    For more info about positioning things with a zoomed camera see my example under my profile: Camera to World Coordinates

    http://gamesalad.com/game/3220

    Edit: I just noticed that the GS website is borked and doesn't display the directions anymore. Anyhow, arrowkeys zoom in and out. Click to move the yellow rect to wherever you click regardless of zoom factor. coordinates are calculated for you.
  • CapitalGamesCapitalGames Member Posts: 5
    The problem with the transparent option is that it won't work for text. If you make the alpha =0 on text, it still stays there. You also have to make the Display Text be blank. Any ideas around that?
  • MotherHooseMotherHoose Member Posts: 2,456
    @CapitalGames... right you are... the alpha in the actor controls the bg of the Display Text...

    but, you can enclose the Display Text in a Rule to respond to a gameAttribute which will determine if it is visible...

    EX: [Rule] when game.Zoom = false (zoom not active therefore you want the Display Text visible)
    --Display Text

    then if the Zoom is true nothing will show in the actor

    MH
Sign In or Register to comment.