advancing animation one frame at a time?

0 favourites
  • 8 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • 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?

  • Try something like this

    On melee attack hit

    .. set enemy animation frame to enemy.animationframe+1

  • Try something like this

    On melee attack hit

    .. set enemy animation frame to enemy.animationframe+1

    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.

  • > Try something like this

    >

    > On melee attack hit

    > .. set enemy animation frame to enemy.animationframe+1

    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.           

    Here's an example:

    Enemy collision stuff

  •    

    Here's an example:

    https://dl.dropbox.com/u/19921470/enemy_collision.capx

    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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I edited the above example a bit, might be a bit more what you are after.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)