Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | EtrnlFlux |
Alright, I’ve been looking at tutorials on youtube to get myself familiarized with Godot.
So far so good, a little hang up as the video is a bit older. The game in question is a brick breaking game. Simple, straight forward. Best way to learn I figured is to tweak it, fiddle, and try to add my own ideas further on it. The snag is I can’t seem to figure out how to spawn a new ball when the old one gets past the paddle.
extends KinematicBody2D
class_name Paddle
const new_ball = preload(“res://Mini Scene/Ball.tscn”)
func _ready():
set_physics_process(true)
set_process_input(true)
func _physics_process(delta):
var y = position.y
var mouse_x = get_viewport().get_mouse_position().x
set_position(Vector2(mouse_x, y))
func _input_event(viewport, event, shape_idx):
if event.type == new_ball.end:
var ball = new_ball.instance()
ball.set_position(position-Vector2(0, 16))
get_parent().add_child(ball)
I apologize if I have totally butchered this, as I am new to this. So far in my readings over the course of several hours, all the text i’ve come across is how to spawn something based on a mouse or the keyboard but I want it to automatically spawn at the point of the paddle.Could I get some help perhaps?
Thank you.
Don’t know if my question got buried. I apologize for beating a dead horse, but I feel that this is a bit of important question to ask. So far, I still have yet to find any way to spawn something without input from the user. Is there anyone out there that is capable of answer this? Would really appreciate it!
EtrnlFlux | 2019-04-19 15:05