Sucking in and Enemy and Spitting them back out.

Get help using Construct 2

Post » Thu Oct 17, 2013 1:23 pm

I have been pouring over the forums and even the "How do I FAQS" (and thanks making those they are all super helpful!) and I haven't been able to find an answer to this. So I do apologize if this topic has come up before.

I wanted to find out how to create the events and behaviors for a character like Yoshi or Kirby from the old SNES games. The main character sucks in enemy with air or tongue and then that character can be shot back out with each bad guy enemy having different attributes. If you suck in a red turtle shell you spit out fire. If you suck in a blue turtle shell it makes you fly if you suck a yellow turtle shell it gives super speed for examples of different behaviors. And I wanted to be able to aim the turtle shells (or enemies) so you can shoot them back out at angle and bouncing off walls a la Yoshi's Island. I'm still new to this and creating projects to help practice and refine things but I am not a big coder, so I figure it would be easier to ask on here for the help. You guys have done such a good job of clearing up and showing examples so I wanted to ask for assistance.

Thank in advance!
Posts: 8
Reputation: 966

Post » Thu Oct 17, 2013 1:35 pm

A basic version of such a mechanic could be implemented by simply giving enemies an instance variable that holds a descriptive function name. Like "firebreath" for example.

Now when the enemy is sucked in and destroyed, a variable of the player sprite is set to "firebreath".

And finally you have your action/attack event or whatever call a function with the name of that player variable. Which in this case is "firebreath" of course.

This way you have a nice workflow and can simply create the appropriately named functions and have them do the stuff that needs to be done. :)
Posts: 1,051
Reputation: 8,173

Post » Thu Oct 17, 2013 1:38 pm

First you will have to set up an event with the conditions for when an enemy can be sucked.


keyboard on space down
system compare two values : distance(player.x,player.y,enemy.x,enemy.y) <= 200

then you should make the sucking action:

enemy set position :
x = lerp(enemy.x,player.x,dt)
y = lerp(enemy.y,player.y,dt)

Then you should have an event on enemy colliding with player.
To make sure the player is sucking you should create an boolean instance variable IsSucking.

keyboard on space pressed: player set variable IsSucking to true
keyboard on space released: player set variable IsSucking to false

enemy on collision with player
player variable Issucking is true :
- enemy destroy

etcetera... (being what @PixelRebirth said)LittleStain2013-10-17 13:40:00
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
Posts: 6,160
Reputation: 19,775

Post » Thu Oct 17, 2013 1:40 pm

Hi ceeBat,

You can give each enemy an instance variable "type"! Then each time you destroy an enemy you can compare type, and if type = fire -> set attack to fireball (or ice, lightning, etc)!

If you search the manual for variables, it should help you!

Good luck with it :)
Posts: 494
Reputation: 8,282

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest