advancing animation one frame at a time?

Get help using Construct 2

Post » Tue Apr 09, 2013 4:01 am

okay, so i am building a pretty straight-forward platformer and i am having trouble assigning a certain behavior to one of my enemies.
i want the player's melee attack against the enemy to advance a separate animation for the enemy by one frame for each collision.
it seems like it shouldn't be as difficult to implement as i am making it. anyone have any ideas?
B
14
S
4
Posts: 15
Reputation: 1,262

Post » Tue Apr 09, 2013 6:57 am

Try something like this

On melee attack hit
.. set enemy animation frame to enemy.animationframe+1
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Tue Apr 09, 2013 7:41 am

[QUOTE=vee41] Try something like this

On melee attack hit
.. set enemy animation frame to enemy.animationframe+1[/QUOTE]

so i've tried that and it doesn't seem to work. what i have going is the enemy has a walking animation that stops when the player gets close (event:Sprite-->Platform On Stopped-->action:Sprite-->Stop animation
                                   -->action:Sprite-->Set anim. frame to 4)
after he stops, i want the player to hit him three times with each hit advancing one frame of animation to show the damage he's taken.
i've named the damage animation 'collapse' so i tried this:
(action:Sprite-->Set frame to (Sprite.Collapse.frame+1)%Sprite.Collapse.Animationframecount)
but that doesn't seem to work. not that i know why it would, i don't really know what i'm doing obviously. haha.
thanks anyway for your help.           
B
14
S
4
Posts: 15
Reputation: 1,262

Post » Tue Apr 09, 2013 8:07 am

[QUOTE=CleverName81] [QUOTE=vee41] Try something like this

On melee attack hit
.. set enemy animation frame to enemy.animationframe+1[/QUOTE]

so i've tried that and it doesn't seem to work. what i have going is the enemy has a walking animation that stops when the player gets close (event:Sprite-->Platform On Stopped-->action:Sprite-->Stop animation
                                   -->action:Sprite-->Set anim. frame to 4)
after he stops, i want the player to hit him three times with each hit advancing one frame of animation to show the damage he's taken.
i've named the damage animation 'collapse' so i tried this:
(action:Sprite-->Set frame to (Sprite.Collapse.frame+1)%Sprite.Collapse.Animationframecount)
but that doesn't seem to work. not that i know why it would, i don't really know what i'm doing obviously. haha.
thanks anyway for your help.           [/QUOTE]

Here's an example:

Enemy collision stuff
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Tue Apr 09, 2013 9:40 am

[QUOTE=vee41]   

Here's an example:

https://dl.dropbox.com/u/19921470/enemy_collision.capx[/QUOTE]

that was really helpful. i still haven't quite figured out how to implement what i want but that has put me much closer. thank you so much!
B
14
S
4
Posts: 15
Reputation: 1,262

Post » Tue Apr 09, 2013 11:17 am

I edited the above example a bit, might be a bit more what you are after.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Tue Apr 09, 2013 4:02 pm

@CleverName81

I'll explain my personal workflow for games like this:

Create an invisible sprite as the player, where I will do all the events.

Create a sprite to be a mask over the real player, it will show all the player animations and is only for this purpose.

Create the follow behaviors:
Invisible Player: Platform; Bound to layout;
Player mask: Pin and deactivate the collision for this object (left menu, on the bottom, lastest option);

Create the follow instance variables:
Invisible Player: attack_ON: false; health: 10;

Configure the platform behavior to meet your requirements.

Now, follow the events:
ON START OF LAYOUT > Set player mask.X -> Invisible Player.X;
> Set player mask.Y -> Invisible Player.Y;
> Pin player mask -> Invisible Player;

Now, go inside the image editor for the player, setup his size and collision polygons to be smaller than the player mask and square, also, put the animation loop OFF;

On the player mask, import the player frames, also, make all the collision polygons to be square, these polygons will not be used on the game. Put the animation to loop or not, do what you feel better.

Separate the animation types, like attack, on another animation name.

Configure the attack animation to be with the frame animation = 0 and setup the looping to not happen.

On the event sheet, do the follow code:
On Key X press > Player Mask animation -> "attack";
> animation frame = "your desired frame";

And ahead.

With a CAPX it would be easier to explain.
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,214
Reputation: 18,486

Post » Wed Apr 10, 2013 5:39 am

TELLES0808, that was very helpful. i figured out how to get the result i wanted with a 'pick instance' event. i'm not entirely sure why it works but it does. however, your workflow is very clean and once i get to cleaning/refining my event sheet, i will reference this closely. thank your very much.
B
14
S
4
Posts: 15
Reputation: 1,262


Return to How do I....?

Who is online

Users browsing this forum: alextro, MarkStockley and 1 guest