Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | heyhowsitgoing |
This is an excerpt of code I have for a game I’ve been working on:
var scene_number = 0
func _on_Area2D_input_event(viewport, event, shape_idx):
if event is InputEventMouseButton:
scene_number += 1
print(scene_number)
func stop_music():
if scene_number == 1:
print("hello")
The scene number updates when I click on a sprite and I’ve confirmed this with a print function, so how come it won’t print out “hello” when the scene_number == 1 (after one mouse click)
In addition to the answers you got, the scene_number
var will also change from being 1 as two events actions happen during InputEventMouseButton
- MouseButton pressed down
- MouseButton press released
So if your stop_music
function is being called maybe try
#if greater than or equal to
if scene_number >= 1:
print("hello")
Wakatta | 2021-09-21 01:06