Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DragonslayerGXZY |
so ive been making fruit ninja because my school gave me the assigment to make fruit ninja and ive been getting this error that says invalid call. nonexistent function ‘interpolate_property’ in base ‘Nil’. and i dont know how to fix it. heres the code where the error is from. plz help this is due monday
for orange splat:
extends Sprite
onready var splat = $splat
onready var fade = $fade
func _ready():
randomize()
# warning-ignore:function_conflicts_variable
func splat():
var r = rand_range(1, 360)
self.rotate(r)
splat.interpolate_property(self, "scale", Vector2(.2,.2),Vector2(1,1) ,.3,Tween.TRANS_QUAD) #this is the code giving the problem
splat.start()
fade()
# warning-ignore:function_conflicts_variable
func fade():
fade.interpolate_property(self, "modulate", Color(1,1,1,1), Color(1,1,1,0), 10,Tween.TRANS_QUAD)
fade.start()
func _on_fade_tween_all_completed():
queue_free()
orange code:
extends RigidBody2D
onready var tween = $Tween
onready var collision = $CollisionShape2D
onready var orangebottom = preload("res://orangebottom.tscn")
onready var orangetop = preload("res://orangetop.tscn")
onready var splat = preload("res://orangesplat.tscn")
func _process(delta):
#area.disabled = true
collision.disabled = true
func _ready():
set_gravity_scale(10)
func fly():
var randomx = rand_range(550, 1000)
var randomy = rand_range(600, 900)
var r = rand_range(200, 300)
rotation_degrees = r
tween.interpolate_property($Sprite, "position", Vector2(0,0), Vector2(randomx, randomy), 1.5, Tween.TRANS_QUAD, Tween.EASE_OUT)
tween.start()
func _on_Area2D_area_entered(area):
var p = get_global_mouse_position()
var ob = orangebottom.instance()
var ot = orangetop.instance()
var splats = splat.instance()
splats.splat()
get_parent().add_child(ot)
get_parent().add_child(ob)
get_parent().add_child(splats)
ob.global_position = p
ot.global_position = p
splats.global_position = p
self.queue_free()
Main world code:
extends Node2D
onready var orange = preload("res://orange.tscn")
#onready var fruits = [orange]
func _ready():
$slice.hide()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Input.is_action_just_pressed("click"):
$slice.show()
if Input.is_action_just_released("click"):
$slice.hide()
func _on_Timer_timeout():
var fruit = orange.instance() #fruits[randi() % fruits.size()]
$spawnpoint.add_child(fruit)
fruit.global_position = $spawnpoint.global_position
fruit.fly()
$Timer.start()
I edited your post to fix the broken code you pasted. In future, hit the “code sample” button when pasting code and it will be formatted correctly.
kidscancode | 2021-05-09 06:36
There are three different places where you call interpolate_property()
, but you didn’t indicate where the error occurred.
Either way, that error means that what you’re calling interpolate_property()
on is null. So at least one of these is invalid:
onready var tween = $Tween
onready var splat = $splat
onready var fade = $fade
kidscancode | 2021-05-09 06:38