How do I create a platformer like Cave Story?

Get help using Construct 2

Post » Thu Mar 22, 2012 8:35 pm

Basically, on the ground, I want to be able to shoot up when up is pressed and left or right when left or right is pressed.

The more trickier part is that in the air, I want to shoot down as well when down is pressed.

Has anyone figured out how to do this? I couldn't find any info on this after a deep search.
B
5
Posts: 13
Reputation: 401

Post » Thu Mar 22, 2012 10:29 pm

Can't you just do the same you did for left/right and up, but use the "Down" key instead? I don't see why it should be more difficult than the other directions.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Mar 22, 2012 11:15 pm

When I shoot up, it would shoot left or right as well, depending on which direction I'm facing.

The same with shooting down.

Here's my CAPX: http://dl.dropbox.com/u/64495006/Solar%20Power%20v0.4.capxAero2012-03-22 23:23:28
B
5
Posts: 13
Reputation: 401

Post » Thu Mar 22, 2012 11:22 pm

Give your player a variable that tells which direction he should be shooting based on input and/or direction.

Player is facing right (not mirrored)? Set variable to 0
Player is facing left (mirrored)? Set variable to 180

User is holding up? Set variable to 270
User is holding down? Set variable to 90

Then when the player shoots, create the bullet and set its angle to the variable. Of course there's a bit more to it but you get the idea o.oTokinsom2012-03-22 23:23:23
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Thu Mar 22, 2012 11:49 pm

Agh, I don't know why, but whenever my guy comes down on the ground while the variable is set to 90, he still shoots down.

I tried to fix it, so when he's facing left and comes down to the ground, he shoots left like he's supposed to.

But when he faces right, he just does nothing.
Here's my CAPX again; same as before. I think the upper-most event (facing left) took priority, and that's why the facing right event won't work, but if that's the case, how do I set them to the same priority?
B
5
Posts: 13
Reputation: 401

Post » Fri Mar 23, 2012 12:05 am

Added a new group at the bottom with working aiming. Download it HERE

Also you might want to change the shoot direction variable to an instance variable for your player; there's no reason to make it global!Tokinsom2012-03-23 00:06:59
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Fri Mar 23, 2012 2:25 am

Wow, the shooting works flawlessly.

Thank you so much!
B
5
Posts: 13
Reputation: 401


Return to How do I....?

Who is online

Users browsing this forum: Matthew de and 19 guests