| Name | Typ | Von |
|---|---|---|
| Check for scene scrolling | Definition | Einzelkämpfer |
Dieses Skript bietet eine Funktion, um zu überprüfen, ob die Szene gerade gescrollt wird.
Anweisungen
- Füge das Hauptskript im Skripteditor von Visionaire Studio hinzu und lege es als Definitionsskript fest.
- Rufe die Funktion "isSceneScrolling()" auf, um zu prüfen, ob die Szene gerade scrollt. Horizontales und vertikales Scrollen kannst du getrennt abfragen.
--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
Hauptskript
-- 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