Panorama scrolling show/hide border arrows

  • #10, by afrlmeTuesday, 28. July 2015, 00:14 9 years ago
    That's not my script it's listing an error from.

    revised script...
    scnSize = nil -- empty variable that we will be storing the scene size into...
    local scn = nil
    
    -- * call this function once at the beginning of each interactive scene * --
    function getSceneSize()
     scnSize = game.CurrentScene.SceneSprite:getSize()
    end
    
    function navArrows()
     if not game.CurrentScene:getBool(VSceneIsMenu) and scnSize ~= nil then
      if game.ScrollPosition.x == 0 then Conditions["Show_Left_Arrow"].ConditionValue = false else Conditions["Show_Left_Arrow"].ConditionValue = true end
      if game.ScrollPosition.x >= (scnSize.x - game.WindowResolution.x) then Conditions["Show_Right_Arrow"].ConditionValue = false else Conditions["Show_Right_Arrow"].ConditionValue = true end
     end
     -- + --
     if scn ~= game.CurrentScene:getName() and not game.CurrentScene:isEmpty() then 
      scn = game.CurrentScene:getName(); startAction("Actions[get_scene_size]")
     end
    end
    
    registerEventHandler("mainLoop", "navArrows") -- create the loop
    

    Please remove whatever other scripts & actions you created for sorting out the arrow hiding / showing.

    Also please remove the "?" symbols from the Show_Right_Arrow? & Show_Left_Arrow? condition names. Symbols can sometimes cause issues when it comes to using Lua script.

    It should work now, providing you do what I just said. - untested mind.

    * edit: updated the script slightly after I quickly tested it. Seems that when you call SceneSprite that you don't need to add .SpriteSprite after it before calling the getSize() function. I don't currently have any scenes greater than the default game resolution for testing, so you'll have to tell me if it's working correctly or not.

    Imperator

    7278 Posts


  • #11, by Simon_ASATuesday, 28. July 2015, 10:51 9 years ago
    Thanks (yes I have disabled the old scripts, removed the "?", etc).

    Well your script is activated and probably "working", because sometimes the arrow hide and show, but it doesn't work as expected.
    With this script, the arrow won't hide immediately when you reach the border of the panorama: it will only hide if you start moving with the cursor to the opposite side (a few pixels back).
    Also, there's a problem in the script with the moment when to show the already hidden arrows. I have tried to make my own changes (see below), but with my script, nothing works anymore.

    scnSize = nil -- empty variable that we will be storing the scene size into...
    local scn = nil
    
    -- * call this function once at the beginning of each interactive scene * --
    function getSceneSize()
     scnSize = game.CurrentScene.SceneSprite:getSize()
    end
    
    function navArrows()
     if not game.CurrentScene:getBool(VSceneIsMenu) and scnSize ~= nil then
    
    -- * hide the left arrow (before reaching 0, or the arrow will not hide) * --
      if game.ScrollPosition.x < 5
      then 
    Conditions["Show_Left_Arrow"].ConditionValue = false 
      end
    
    -- * show the previously hidden left arrow (when reaching the right border of the screen (not picture)) * --
    -- * it has to be a limited area or it will also activate the right arrow scripts below * --
      if game.ScrollPosition.x > game.WindowResolution.x and < (game.WindowResolution.x +5)
      then
    Conditions["Show_Left_Arrow"].ConditionValue = true 
      end
    
    -- * hide the right arrow (before reaching the right border of the panorama image, or the arrow will not hide) * --
      if game.ScrollPosition.x > (scnSize.x - 5) 
      then 
    Conditions["Show_Right_Arrow"].ConditionValue = false 
      end
    
    -- * show the previously hidden right arrow (when reaching the left border of the screen (not picture)) * --
    -- * it has to be a limited area or it will also activate the left arrow scripts above * --
      if game.ScrollPosition.x  ((scnSize.x - game.WindowResolution.x) - 5)
      then
    Conditions["Show_Right_Arrow"].ConditionValue = true 
      end
    end
    
     -- + --
     if scn ~= game.CurrentScene:getName() and not game.CurrentScene:isEmpty() then 
      scn = game.CurrentScene:getName(); startAction("Actions[get_scene_size]")
     end
    end
    
    registerEventHandler("mainLoop", "navArrows") -- create the loop
    


    I don't currently have any scenes greater than the default game resolution for testing

    In fact you do have one: the ved file that I shared last week for the preview of my game grin (remember? when we were trying to work on dynamic music scripts)

    Great Poster

    321 Posts

  • #12, by afrlmeTuesday, 28. July 2015, 15:01 9 years ago
    I've no bloody clue. I've tried a few other quick methods & no matter which method is used it will only update the arrows when you move the cursor away from the edge of the viewport. The only thing I can think of is that when scroll scene with cursor on edge option thing is active & that cursor is on edge triggering scene scroll action that it somehow prevents the ScrollPosition field from being read. It's weird. I even tried adding the queries into some animation frames too.

    Imperator

    7278 Posts

  • #13, by Simon_ASATuesday, 28. July 2015, 15:19 9 years ago
    ok, no problem Lee. Please don't lose your time on it, I'll just leave the arrows never hidden (like in ASA), it's not that important. Thanks a lot for your help!

    Great Poster

    321 Posts