
My scene setup image direct link
Thanks for you answer. Can you tell what causes it to increase memory (For example a checklist)
It is my scene setup and i repeat these in other level. Level by level some object (like bricks) and animation are increase.
"audio" have several sound (StreamPlayer type).
"camera" have a code for shaking when ball is lose. (I learn this code from Angega Studios youtube user)
"Player" and "enemy" have 2 animation and i set those to play random when finished animation.
func _ready():
anim.connect("finished", self, "_random_animation")
func _random_animation():
var randNum = randi() % 2
if randNum == 0: anim.play("idle")
else: anim.play("ready")
"brick container" have 24 bricks, and level by level these will be increase.
"ball" have a for loop condition for collision check and bricks queue_free, play sound when contact to object. and a condition for check ball that when ball get out at scene, reset ball position for new game.
func _fixed_process(delta):
if _global.is_ball_play && self.get_global_pos().x <= 0:
self.set_sleeping(true)
self.set_pos(Vector2(220, 190))
_global.is_ball_play = false
container.add_child(fade_white.instance())
_global.player_life -= 1
camera.shake(8, 0.2)
ballSpeed = BALL_SPEED
if _global.is_sfx:
snd_ball_gone.play()
# Colliding ball
var collision = get_colliding_bodies()
for i in collision:
ballSpeed += 3
ballSpeed = clamp(ballSpeed, BALL_SPEED, BALL_SPEED*2)
# Ball sound
if _global.is_sfx:
snd_ball.play()
if i.is_in_group("g_brick"):
i.queue_free()
# Change direction ball by hit
if i.get_name() == "hit_player":
var p = i.get_node("position2D").get_global_pos()
var changPos = self.get_global_pos() - p
var velocity = changPos.normalized() * ballSpeed
self.set_linear_velocity(Vector2(velocity.x, velocity.y))
"container" is a place for add "white fade-out animation" when ball is lose and "hit shape" for change direction ball (like a paddle), and after finished animation these will be queue_free.
"ui" is a simple menu for go to next level, close or restart game.
I hope these information be enough