Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node2D
- # sers variable score to 0
- var score = 0
- # Used to initialise program. Put variables here.
- # -> void means a value is not returned. You can leave this out if wanted.
- func _ready() -> void:
- # Shows score on screen as 0
- $CanvasLayer/RichTextLabel.text = str(score)
- # when button pressed adds 1 to score and plays sound. If score is greater than 10, reset to 1.
- func _on_texture_button_pressed() -> void:
- # this is the same as score = score + 1
- score += 1
- if score > 10:
- score = 1
- $CanvasLayer/RichTextLabel.text = str(score)
- $CanvasLayer/AudioStreamPlayer2D.play()
- # add a different sound when score = 10
- # add new textbox that shows "hello world" when score == 10
- # add a new button that changes count.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement