Scene Zoom

  • #1, by darren-beckettFriday, 26. June 2015, 16:37 9 years ago
    Hi,
    Is there a way a user could adjust the zoom of a scene at run-time?
    I'd like to enable a multi-touch zoom in?

    Great Poster

    384 Posts


  • #2, by afrlmeFriday, 26. June 2015, 17:01 9 years ago
    Yes, you could use the shader toolkit shaderViewport() function to zoom in/out, rotate the screen & various other things with easing options.



    P.S: you need Visionaire Studio 4.1 onwards to use the current shader toolkit script.

    Imperator

    7278 Posts

  • #3, by MachtnixFriday, 26. June 2015, 17:16 9 years ago
    Geht das auch ohne Toolkit? Z.B. durch eine Klick-Aktion, die den kompletten Hintergrund plus Objekte auswechselt?

    Possible without this toolkit? Maybe to change the complete background with an action?

    Thread Captain

    1097 Posts

  • #4, by ke4Friday, 26. June 2015, 18:13 9 years ago
    You could make it as an animation or you could change the size of the background via lua script. There's no action for changing the size of objects hovewer you can change the size of animation. You would have to set the background as one frame looping animation and then control the size through lua script.

    Key Killer

    810 Posts

  • #5, by darren-beckettSaturday, 27. June 2015, 11:19 9 years ago
    The ShaderToolkit seems to almost do what i require.

    shaderZoom works well, but it doesn't center on the current character.
    But, shaderZoomCharacter zooms the current character to the center of the screen even if this they're at the edge of the screen, which results in a black area.

    Great Poster

    384 Posts

  • #6, by afrlmeSaturday, 27. June 2015, 11:53 9 years ago
    Yeah, err we need to add a bit of code to the zoom, pan & follow functions to prevent the viewport from going past the background image - that's why you can see black.

    The viewport should go no less than 0, 0 on both x & y & no more than scene background width & height minus default game resolution x & y.

    Imperator

    7278 Posts

  • #7, by darren-beckettSaturday, 27. June 2015, 18:26 9 years ago
    Thanks, i've now sorted the 0.
    How do i obtain the scene background width & height?

    DefaultGameRes = game.WindowResolution.x & y
    SceneBackgroundHeight = ???

    Great Poster

    384 Posts

  • #8, by afrlmeSaturday, 27. June 2015, 18:52 9 years ago
    Hmm...
    local ss = game.CurrentScene.SceneSprite.SpriteSprite:getSize()
    print(ss.x, ss.y) -- print scene width & height to log
    


    Simon told me a while back that it's not a good idea to keep calling the getSize() function (for some reason or other - I forget), so I recommend creating a little function that you call once inside of an at begin of scene action for each scene. That way you can update a Lua variable with the current scene width once & access it in your other scripts (well if you use a global variable instead of local).

    Imperator

    7278 Posts

  • #9, by darren-beckettSunday, 28. June 2015, 17:06 9 years ago
    This works well, but it doesn;t follow the character.
    I've tried shaderFollowCharacter, but it doesn't do anything. is there something i need to call to enable mainLoop?

    Great Poster

    384 Posts

  • #10, by afrlmeSunday, 28. June 2015, 20:18 9 years ago
    I'm not sure if scroll position is updated to zoomed scale factor. Probably something worth looking into. Maybe I'll do that at some point, when I have a minute - & if I remember (terrible memory).

    Imperator

    7278 Posts

  • #11, by dos4gwSaturday, 19. September 2015, 04:44 9 years ago
    Can the shader toolkit be used in games that will be put up for sell?

    Newbie

    69 Posts