Help with sword attack

Get help using Construct 2

Post » Thu Apr 11, 2013 7:20 pm

Hello everyone,

I'm creating a platform game and I'm having some issues with my sword attack. Here is my demo https://dl.dropboxusercontent.com/u/8017129/folclore-minado/index.html. and here is my .capx file https://dl.dropboxusercontent.com/u/8017129/folclore-minado/capxfile.capx

First problem: When I'm facing left, my sword attacks to the right anyway.I already tried to use the mirror effect but nothing happen.

Second problem: As you can see, it's taking too long to my sword spawn another object to collide with the enemy and kill it. And if I jump and attack at the same time, my player create spawn object at wrong positions and times. I know I have to destroy the spawn object, but I didn't yet because this problem.

To jump is up arrow
To walk is left and right arrow
And to attack is Z

Hope somebody can help me out, thanks in advance! almeidamarcell2013-04-11 19:21:51
B
16
S
4
G
4
Posts: 56
Reputation: 2,942

Post » Thu Apr 11, 2013 7:54 pm

[QUOTE=almeidamarcell]First problem: When I'm facing left, my sword attacks to the right anyway.I already tried to use the mirror effect but nothing happen.[/QUOTE]

This is because you're moving the sword by changing it's angle. If you set a sprite's angle to 45 degrees, it won't change angles by mirroring the sprite. If you want to swing the swrong to the left by changing the sprite's angle, you'll need to move the sprite in the opposite direction as a right facing swing.

I think you'd be much better of creating an animation of the sword swinging rather than manipulate its angles. That way, mirroring the sprite would work, and you wouldn't have to fool around with wait commands (see 2nd issue). However, I've never messed around with sword mechanics in C2, so perhaps someone with experience can comment on which method is appropriate.

[QUOTE=almeidamarcell]Second problem: As you can see, it's taking too long to my sword spawn another object to collide with the enemy and kill it. And if I jump and attack at the same time, my player create spawn object at wrong positions and times. I know I have to destroy the spawn object, but I didn't yet because this problem.[/QUOTE]
This is due to all the wait commands. You have the sword finish swining, and then a wait command of 0.5 seconds, and then the hitbox is created. Those 0.5 seconds are what is causing the delay. Spawning the hit box before the wait command is a quick fix.

I made a few changes to your capx that that fix the issues you discussed, but it's probably worth exploring other more efficient sword mechanics.
Capxzatyka2013-04-11 19:57:09
B
44
S
13
G
7
Posts: 338
Reputation: 10,379


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests