Difference between revisions of "Check For Scene Scrolling"
From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 51: | Line 51: | ||
registerEventHandler("mainLoop", "checkScrolling") | registerEventHandler("mainLoop", "checkScrolling") | ||
+ | |||
+ | ------------------------------------------- | ||
function isSceneScrolling(dir) | function isSceneScrolling(dir) |
Latest revision as of 23:35, 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