Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```swift
- extends Node2D
- var x = 50
- var stateOne
- var stateTwo
- signal is_jumping
- signal is_grounded
- func _ready():
- self.stateTwo = StateTwo.new()
- self.stateOne = StateOne.new()
- self.connect("is_jumping",self.stateOne,"Jumping")
- self.connect("is_grounded",self.stateTwo,"On_ground")
- set_process(true)
- func _process(delta):
- if x <10:
- is_jumping()
- else:
- is_grounded()
- func is_grounded():
- emit_signal("is_grounded")
- func is_jumping():
- emit_signal("is_jumping")
- class StateTwo extends Object:
- func On_ground():
- print("character is on the ground")
- class StateOne extends Object:
- func Jumping():
- print("character is Jumping")```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement