How to Make a Balloon Pop | Android

ToliToli Posts: 2Applicant

hi guys,
I'm rather new to the subject programming or game engine so bear with me.
If been through some tutorials now, but when it comes to programming in gdscript from the scratch I still stumble upon some problems.

My Question:
How do I check for the Input in a specific area, say a balloon? My plan is to let Ballons randomly rise from the bottom of the screen and the player has to pop them by tapping on them on the screen. My initial thought was to make buttons instead of rigid bodies, but I also want to play a popping animation when the balloon is hit.

I hope some of the programming pros here can help me out or can support me with a tutorial :)

Thank you very much!

Tags :


  • RossRoss Posts: 180Member
    edited December 2016

    You could use buttons, that's a good idea, but by default you only get rectangular collision with buttons. TextureButtons let you set a "Click Mask", which sounds like it would let you set any collision shape you want, but how that works and how to create the mask is undocumented. There is a create_from_image_alpha() function that looks promising, but you never know.

    You can easily play a popping animation with a button. Just connect() the pressed or button_down signal to a function in your script that starts the animation.

    Or, you could give your balloons some kind of node with collision (Area2D, KinematicBody2D, RigidBody2D) with any shape you want, and do a point trace at the tap position to check if it hits anything. To check for collisions at a point, do: get_world_2d().get_direct_space_state().intersect_point(Vector2 point). It basically gives you an array of objects hit (empty if nothing is at that point). Check the docs for the details of how that works.

  • ToliToli Posts: 2Applicant

    Thank you very much, I'll give it a try!

Sign In or Register to comment.