After setting Horizontal scroll area, the character doesn't "push" the scene edges any more

  • #1, by andiliddellTuesday, 13. January 2015, 11:16 10 years ago
    Hi All

    Not entirely sure if this a bug, or I'm not understanding correctly?

    I'm trying to change scenes to a scene which is twice the length of the game width, but the character starts in the new scene at the right hand side.

    I've used the "set horizontal scroll" action to make sure the camera has a left border position of 1280 when the scene starts (framing the character at the right hand end of the long room). I didn't set a right border, is this correct?

    The problem is once the player starts to walk to the left, the room doesn't auto-scroll with him any-more. see diagram

    I've tried setting "centre screen on character" but that doesn't return the default behaviour of the character "pushing" the screen view-port along as he reaches the end either?

    Can Anyone shed any light on this? Am I forgetting something basic?

    Thanks in advance.
    Andi

    Forum Fan

    178 Posts


  • #2, by afrlmeTuesday, 13. January 2015, 11:37 10 years ago
    Hmm... I think it's because you have cut out that part of the scene. The horizontal/Vertical scroll borders are used to set the playable area of a scene, if I remember correctly, so I'm not sure what you are trying to achieve with them.

    If you are wanting to adjust the amount of distance from the edge of the screen (current viewport, not entire scene) the character has to be to trigger scene scroll then you can use these 2 lines of Lua script.
    -- set distance from viewport edge (in px)
    game.HorizontalScrollDistance = 100
    game.VerticalScrollDistance = 100
    


    What you have done with those action parts is define the scrollable area...


    SceneScrollableArea

    Usually the scene can be scrolled to the edge in each direction. This area can limit the scrolling in each direction so the scene can not be scrolled to the edge.

    Imperator

    7278 Posts

  • #3, by andiliddellTuesday, 13. January 2015, 11:50 10 years ago
    Ahh I see, so how do I get the view-port to start in the position shown in my diagram then?

    Is there an action for that, I've tried "scroll to position/object", but that actually animates to a position, I need it to be set, so when the scene fades in the view-port is in exactly the right place.

    Forum Fan

    178 Posts

  • #4, by afrlmeTuesday, 13. January 2015, 12:13 10 years ago
    try adding a line of lua script in an execute a script action part.
    game.ScrollPosition = {x = 1280, y = 0}
    

    I can't guarantee it will work though as character usually takes precedent over the position of the camera, unless you turn off character centering, with the action part you mentioned earlier.

    Imperator

    7278 Posts

  • #5, by andiliddellTuesday, 13. January 2015, 12:45 10 years ago
    Cheers , Ill give this a shot when I get home

    Forum Fan

    178 Posts

  • #6, by afrlmeTuesday, 13. January 2015, 13:03 10 years ago
    You could probably extend that line further if you wanted to by query the position of the character on scene start.

    if game.CurrentCharacter.Position.x < 1280 then
     game.ScrollPosition = { x = 0, y = 0}
    else
     game.ScrollPosition = { x = 1280, y = 0 }
    end
    

    ...as a quick example. This would set scroll position to furthest left or to the position you defined.

    Imperator

    7278 Posts

  • #7, by andiliddellTuesday, 13. January 2015, 19:44 10 years ago
    I used a combination of action parts and the one liner script to:

    Ignore character position
    Set scroll position (with script)
    Pause
    Start using character for scroll again

    This works perfectly! Thanks

    Forum Fan

    178 Posts

  • #8, by afrlmeTuesday, 13. January 2015, 19:53 10 years ago
    No worries. smile

    Imperator

    7278 Posts