0 votes

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

func stop_music():
     if scene_number == 1:

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 Engine by (12 points)

In addition to the answers you got, the scene_number var will also change from being 1 as two events actions happen during InputEventMouseButton

  1. MouseButton pressed down
  2. MouseButton press released

So if your stop_music function is being called maybe try

#if greater than or equal to
if scene_number >= 1: 

2 Answers

0 votes

Nowhere in your code snippet does stop_music() get called.

by (401 points)
0 votes

That would depend on when the stop_music() function is being called. Try to print something *before* the if statement, to see if the function is fired at the appropriate time.

by (1,305 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.