[ask] got error on class extends

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By roxas4sora

sorry for my bad english
i want to ask why i got error, i am super newbie at this game dev even progammer

i try to make flappy bird tutorial from youtube, and then got error when extends class i dunno why i got error
here code

extends RigidBody2D

onready var state = FlappingState.new(self)

const STATE_FLYING = 0
const STATE_FLAPPING = 1
const STATE_HIT = 2
const STATE_GROUNDED = 3

func _ready():
#$anim_sprite.play(“flying”)
set_process_input(true)

func _physics_process(delta):
state.update(delta)
print(linear_velocity)
pass

func _input(event):
state.input(event)

func set_state(new_state):
state.exit()

if new_state == STATE_FLYING:
	state = FlyingState.new(self)
elif new_state == STATE_FLAPPING:
	state = FlappingState.new(self)
elif new_state == STATE_HIT:
	state = HitState.new(self)
elif new_state == STATE_GROUNDED:
	state = GroundedState.new(self)
pass

func get_state():
if state extends FlyingState:
return STATE_FLYING
if state extends FlappingState:
return STATE_FLAPPING
if state extends HitState:
return STATE_HIT
if state extends GroundedState:
return STATE_GROUNDED
pass

Flying State ------------------------------------------------

class FlyingState:
var bird

func _init(bird):
	self.bird = bird

func update(delta):
	pass
	
func input(event):
	pass

func exit():
	pass

Flaping State ------------------------------------------------

class FlappingState:
var bird

func _init(bird):
	self.bird = bird
	
	bird.set_linear_velocity(Vector2(50, bird.get_linear_velocity().y))
	pass

func update(delta):
	
	if rad2deg(bird.get_rotation()) < -30:
		bird.set_rotation(deg2rad(-30))
		bird.set_angular_velocity(0)
	
	if bird.linear_velocity.y > 0:
		bird.set_angular_velocity(1.5)
	pass

func input(event):
	if Input.is_action_just_pressed("klik_kiri"):
		flap()
	
	pass
	
func flap():
	bird.set_linear_velocity(Vector2(bird.get_linear_velocity().x, -150))
	bird.set_angular_velocity(-3)
	pass

func exit():
	pass

Hit State ------------------------------------------------

class HitState:
var bird

func _init(bird):
	self.bird = bird

func update(delta):
	pass

func input(event):
	pass

func exit():
	pass

Grounded State ------------------------------------------------

class GroundedState:
var bird

func _init(bird):
	self.bird = bird

func update(delta):
	pass

func input(event):
	pass

func exit():
	pass

:bust_in_silhouette: Reply From: curiousdev

Maybe you should replace ‘extends’ with ‘is’ ?

wow, is works thank >_<

roxas4sora | 2018-07-20 09:36