blob: 6be1a263a243d7b79cb70580ccd8bb044ac25fbe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
extends Node
# This script creates and attaches all the wheels. Depending on the variables
# given to this script, it can generate different type of vehicles
# Called when the node enters the scene tree for the first time.
func _ready():
createWheel("front", [17,-27])
createWheel("front", [-17,-27])
createWheel("back", [20,36])
createWheel("back", [-20,36])
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func createWheel(type,dataArray):
if(type == "front"):
var wheeltemp_resource = load("res://4WheelCar/FrontWheel.tscn")
var wheeltemp = wheeltemp_resource.instance()
wheeltemp.set_position(Vector2(dataArray[0],dataArray[1]))
add_child(wheeltemp)
wheeltemp.initVars(dataArray)
# add_child(tempA)
elif(type == "back"):
var wheeltemp_resource = load("res://4WheelCar/BackWheel.tscn")
var wheeltemp = wheeltemp_resource.instance()
wheeltemp.set_position(Vector2(dataArray[0],dataArray[1]))
add_child(wheeltemp)
wheeltemp.initVars(dataArray)
|