Difference between revisions of "Check For Scene Scrolling"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="ts" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |- | Check for scene scrolling || Defini...") |
|||
Line 11: | Line 11: | ||
== Instructions == | == Instructions == | ||
# Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor and set the script as a definition script. | # Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor and set the script as a definition script. | ||
− | # Call the | + | # Call the "isSceneScrolling()" function to check for a currently scrolling scene. You may check for horizontal or vertical scrolling separately. |
<syntaxhighlight lang="lua" id="txt"> | <syntaxhighlight lang="lua" id="txt"> | ||
--Check if scene is currently scrolling in any direction | --Check if scene is currently scrolling in any direction |
Revision as of 23:24, 21 September 2023
Name | Type | By |
---|---|---|
Check for scene scrolling | Definition | Einzelkämpfer |
This script provides a function to check if the scene is currently scrolling.
Instructions
- Add the main script to the Visionaire Studio Script Editor and set the script as a definition script.
- Call the "isSceneScrolling()" function to check for a currently scrolling scene. You may check for horizontal or vertical scrolling separately.
--Check if scene is currently scrolling in any direction
isSceneScrolling() -- returns boolean
-- Check if scene is currently scrolling in horizontal direction
isSceneScrolling("h") -- returns boolean
-- Check if scene is currently scrolling in vertical direction
isSceneScrolling("v") -- returns boolean
Main Script
-- Call "isSceneScrolling()" to check if a scene is currently scrolling
is_scrolling_h = false
is_scrolling_v = false
last_scene = game.CurrentScene
last_pos = game.ScrollPosition
function checkScrolling()
cur_scene = game.CurrentScene
cur_pos = game.ScrollPosition
if cur_scene == last_scene then
is_scrolling_h = (cur_pos.x ~= last_pos.x)
is_scrolling_v = (cur_pos.y ~= last_pos.y)
else
last_scene = cur_scene
is_scrolling_h = false
is_scrolling_v = false
end
last_pos = cur_pos
end
registerEventHandler("mainLoop", "checkScrolling")
function isSceneScrolling(dir)
if dir == "h" then
return is_scrolling_h
elseif dir == "v" then
return is_scrolling_v
else
return (is_scrolling_h or is_scrolling_v)
end
end