+1 vote

I made the viewport as a barrier / a wall to hold the blocks for a game like candy crush.I used kinematicbody 2D for the blocks and attached the code like this

 var extents
 var screensize
 var pos
 var velocity = Vector2()

 func _ready():
       screensize = get_viewport_rect().size
       extents = $Sprite.get_texture().get_size() / 8
       pos = screensize / 8      

 func _physics_process(delta):
       velocity.y += gravity * delta
       position.y += velocity.y * delta
       move_and_collide(velocity * delta)
       pos += velocity * delta
       if pos.x >= screensize.x - extents.x:
           pos.x = screensize.x - extents.x
           velocity.x *= 0
       if pos.x <= extents.x:
           pos.x = extents.x
           velocity.x *= 0
       if pos.y >= screensize.y - extents.y:
           pos.y = screensize.y - extents.y
           velocity.y *= 0
       if pos.y <= extents.y:
           pos.y = extents.y
           velocity.y *= 0

When I execute it the viewport acts as a wall/barrier.But during spawning the blocks are held by the viewport wall.When the lower blocks are cleared the upper blocks do not come in the place of the cleared blocks but stay where they where and comes down only when more blocks fall on them.How can I make the blocks to fall freely without staying where they where when the blocks below them are cleared ?

in Engine by (141 points)

Hi it me again and I make some research and I find this serie of tutorial I don't know if you already see it but anyway there the link:Make a macth 3 game like candy crush

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.