{Solved} Change an object image/sprite in event sheet

0 favourites
  • 8 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello,

    Forgive me if this is such a simple question, i have searched the forum and used search engines to try and find the answer with no luck.

    I am making a platform game where i would live to change the sprite using event sheet after a button is pressed. So if you press SPACEBAR then the sprite will change the hero into a hero with sword sprite i have made, for a few seconds, then revert back.

    Then i can add collision events where if the enemy if the enemy collides with the non-sword sprite the hero dies. And if the enemy collides with the sword sprite the enemy dies.

    Thanks for reading,

    Phil

  • Hi PhilWilky

    I believe the best way to do this is through an animation. First insert frames in the sprite with all the heroes and change the speed to zero. Then put an event to change the frame of this sprite each time you press the space key.

    First add the "keyboard" object.

    Event: on "space" pressed

    Action: Sprite>> Set animation to frame 1

    Good lucky!

  • Hi RenatoB

    Thanks for the help that works perfectly.

    It changes to attack sprite on frame 1 then waits two seconds then reverts back to original sprite frame 0.

    if people were to want help on doing this then this is the working event sheet.

    Another big thank you RenatoB.

    Phil

  • Hi PhilWilky

    I believe the best way to do this is through an animation. First insert frames in the sprite with all the heroes and change the speed to zero. Then put an event to change the frame of this sprite each time you press the space key.

    First add the "keyboard" object.

    Event: on "space" pressed

    Action: Sprite>> Set animation to frame 1

    Good lucky!

    Looking at the collision. I am having trouble connecting 'is animation playing' event to get collision when the sword sprite is showing.

    In other words i can connect player collision with enemy no problem but trying to connect the animation frame with collision seems to be hard.

    Thanks,

    Phil

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi PhilWilky

    I do not know if I understood your needs, but if the issue is collision when change the frame, you can resolve this by setting the boundaries of the collision polygon.

    Open the "Edit image" window and click "Set collision polygon", then click the right mouse button on one of the points and choose "Guess polygon shape" and make adjustments as necessary.

  • Hi PhilWilky

    I do not know if I understood your needs, but if the issue is collision when change the frame, you can resolve this by setting the boundaries of the collision polygon.

    Open the "Edit image" window and click "Set collision polygon", then click the right mouse button on one of the points and choose "Guess polygon shape" and make adjustments as necessary.

    Hi,

    Its not that hrm.

    okay so now i have one object and two sprites on that object. Now i need some how to test which sprite is active. So when the enemy collides with the hero object i need the level to restart, now that's easy. But adding a collision to the hero with sword is not working i have tried.

    Sorry cannot think of anyway to make this clearer.

    Phil

    adding the event "'is animation playing" to see if the sword hero is active then adding a collision event. Then destroy enemy sprite. but this is not working.

  • PhilWilky

    It's easier when we can see the CAPX, but I think I get it now. You need to compare the frame when occurs collision between the sprites.

    Event: Sprite (hero) >> On collision with another object (on collision with enemy)

    Subevent: Sprite (hero) >> compare frame (= Animationframe hero / sword frame number)

    Action: Destroy enemy

    I hope now your problem has been solved.

  • RenatoB

    Hi sorry i did not know i could do that. Yea that as worked thanks did not know about sub events so great to know. Thanks again for all your help.

    This is it in full if anyone wants to see.

    Phil

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