My animations aren't working properly

0 favourites
From the Asset Store
_______ Huge collection of metal fixtures ________
  • Hello,

    I have some problems concerning animations in construct 2.

    There is my situation : I have a ship than can shoot laser. This ship has 3 colors which represent 3 states : Yellow red and blue. (It's an Ikaruga like for theses who knows).

    Besides this, there is asteroids that are blue or red. So depending on the states of my ship the player gains more or less points.

    Yellow state is 1 point no matter the color of the asteroid.

    Blue stat is 2 for blue asteroid and 0 for red. Reciprocal for red.

    But this isn't my problem (yet, at least). What I want is when the player press "shit" the ship become blue (done) and when i press ctlr the shipe become red (done aswell).

    BUT. On this I have one big problem and maybe something to optimise the gameplay.

    FIRST PROBLEM : The ship become red or blue but the laser is still yellow, no matter what. (In the debug i've saw that the old laser (already shooted) chance states but not the new one).

    So i need to know how to put red or blue for my laser, dependings of the color of my ship (blue for blue / red for red ofc).

    Then for the optimisation i'm wondering if it's possible to push only ctrl to change the color of my ship (tried but ain't working in the way i found).

    There is some screens to make helps easier for you.

    The settings of my frames. Working in the exact same way for the lasers. (frame 0 = red ; frame 1 = yellow ; frame 2 = blue in the same animation)

    And now my event settings. I have the space key to shoot (it stop the animation so it stays yellow at the beginning since my yellow isn't the last frame). And I have the shit / ctrl pressed where i try to treat my ship + laser in the same way, it works for the ship but not for the laser, so i'm quite lost :/

    ---------------------------------------

    EDIT 1 (06/10) :

    I've worked on something else to wait people to answer and i'm like mind fucked.

    I wanted to put an explosion animation so i've added an animation named explosion and putted multiple explosions in frames so this case is settled. I've added it on my event, when my sprite is destroyed it is supposed to play the animation "explosion" like we can see on screen, but when i'm trying to play it, nothing happening, so i'm lost :/

    Thank you very much

  • I'm having some trouble understanding your issue but with the code you have outlined in red, try using sub events.

    Keyboard > ESpace is Down

    (sub event) > Every 0.2 seconds > Ship > Spawn Laser

    ( create a second condition)

    Laser > on created > System wait 0.2 seconds

    > Destroy Laser

    The explosion problem is your destroying it before the animation can play. It should be handled in the 3rd line:

    Asteroid > On collision with laser > asteroid > Spawn Explosion

    > destroy > asteroid

    The explosion needs to be a separate sprite and needs to be spawned just before the asteroid is destroyed.

  • Yeah well, it's hard to tell without a capx to try and see, but hey why are you stopping the animation after each frame change -- it's easier and safer just to set the animation speed (first image, under Animation 'Default' properties) to zero, and then you can just set the frames at ease.

    Im not sure if that would fix you tho, you may need to use some System>Loops>ForEach conditions here or there...

  • FIRST PROBLEM : The ship become red or blue but the laser is still yellow, no matter what. (In the debug i've saw that the old laser (already shooted) chance states but not the new one).

    So i need to know how to put red or blue for my laser, dependings of the color of my ship (blue for blue / red for red ofc).

    --> try to compare the animation like this

    STARTLAYOUT > stop all animation

    if animation Red is on then spawn red laser

    i dont know if this will help you

  • TheDom

    [quote:31071e0u]Keyboard > ESpace is Down

    (sub event) > Every 0.2 seconds > Ship > Spawn Laser

    ( create a second condition)

    Laser > on created > System wait 0.2 seconds

    Destroy Laser

    I'm not understanding this part. Doing a destroy on laser after 0.2 secs is just making my laser pop and destroy it almost right after.

    For the animation it's barely good, it's working (and was such a stupid mistake x) ) but my animation is waaaay smaller than my original sprite, so we barely see it when it explode.

    EDIT 1 : There is no animation problem, I've made it the way you say (haven't saw before ><), by doing a sprite and now working as hell

    -----------------------------

    Yeah the speed sets was a better idea. I don't get why and where I shall uses the loops ? (I'm a total beginner ^^')

    -----------------------------

    clarkkentnicdao

    Kind of helped me since it gave me an idea which is almost working .

    -----------------------------

    For everyone

    First of all there is my capx at this point drive.google.com/open?id=0B6phdwDtsxJkTXN1RnU3TUYyMDA

    Then my update is, i've found the way of putting the right frame so my red ship shoot red laser, same for blue. But the prob here is the last laser shooted is always yellow, no matter how many lasers i shoot the last one (until i shoot again, then it switch to the ship color)

    So i guess that's because i'm setting the animation when i press space right before it spawns like we can see there (for those who don't want to DL my capx)

  • yeah, nevermind the loops! im not that good at coding

  • For your code here outlined in red I don't believe it will create the desired effect.

    This is checking every 0.2 seconds to see if escape button is down. It is NOT activating when escape is down and pausing 0.2 seconds. With such short time it may not be noticeable if you hold down the button. But if you were tapping the escape button and it coincided hitting in between the 0.2 seconds then nothing would be happening. Suggestion would be to have a "ready" instance boolean or something similar.

    Also, I don't know what you are doing exactly, but not sure why you have the spawn a laser after setting the animation for the laser. I believe the way you have it the changing the animations of the laser will affect all of the lasers on the screen then spawn a new one that is unaffected by those actions. If you put the spawn before then the animation actions will only affect the spawned laser.

  • [quote:36touem4]Suggestion would be to have a "ready" instance boolean or something similar.

    Could you tell me a bit more about this ? Like i said i'm a beginner (this is my first real project) and i've never used booleans on construct 2 so i'm kind of lost :p.

    And i'm very intereset of doing the best I can for this project before I have to get it back

    And about the second part, yh i've changed and put the spawn before setting the animation and it works perfectly. Was kinda confused in my mind.

    I tought it was setting the animation (so the colour) and then create the laser so i tought it would have been more efficient that way, should have tried both way x)

    EDIT : The project : drive.google.com/open?id=0B6phdwDtsxJkTXN1RnU3TUYyMDA

    From this i'm wondering a thing because i'm totally lost in the even sheet. I'm doing the scoring so I want to do some conditions like this

    Laser on collision with asteroid
    {
    if (laser.frame=blue&asteroid.frame=blue)
    add score 2
    
    else if (laser.frame=red&asteroid.frame=red)
    add score 2
    
    else 
    add score 1
    }[/code:36touem4]
    
    I know how to do it with code but not in construct 2 so it kinds of bore me and wondering how to do it ?
  • Boolean is just a variable that can only be "true" or "false". To create an instance variable (as opposed to global variable) you click on an object and add it via the properties bar (initially on the left).

    What I was implying was replace 'every 0.2 seconds' with 'ship.ready' (meaning boolean is true). Then add an action to that event that changes the boolean to false. To have it change back to true every 0.2 seconds add the timer behavior and create an action to start a timer. Then create a 'on timer' event that changes the boolean back to true. (you could use wait but will most likely lead to bugs in the future)

    This variable can be helpful in the future also for when game is paused or maybe ship gets stunned or something, just have to change the boolean to false.

    I understand your thinking on setting the animation before it is spawned, I kind of had the same lines of thinking at first. But remember how fast all of this can be processed but also was probably setup to actually process those actions at once.

    If you want to replicate that in construct you just need some sub-events, which are visually indented and work like a nested if, and the else command, which is in the system events. The else command will fire if the command above it fails. You can have multiple conditions but the else has to be at the top of them. It will be apparent if the else command is setup wrong.

  • Fixed the first part (with boolean/shoot and stuff, perfectly working.)

    But, I still have a problem with the scoring. I've tried the else stuff and it's very complicated and I don't understand.

    So i've found an other way to do it. I've added variable named state into my laser and my asteroid. So when i want to score I compare the state of the asteroid and laser.

    So, if laser.state = asteroid.state then it adds +2 ; if it's not equal it adds +1. The +1 thing is working but not the +2.

    The good things is, I know why but I doesn't know how to fix it. When I press "shift" or "ctrl" to set the red/blue color to my ship it is supposed to change the animation of my laser and change the color, it works, but in the same event it's supposed to also change the state of my variable (putting 0 or 1 dependings of the ship color) but it's just never change and I don't get why. :/

    There is a screen of my even sheet and my capx there : drive.google.com/open?id=0B6phdwDtsxJkTXN1RnU3TUYyMDA

  • I can see what's gone wrong here but it's getting a little messy. You should really override everything that happens with the ship's state as primary comparison.

    Space pressed > if ship anim=2 then spawn a laser and set laser state to 0

    > if ship anim=0 then spawn a laser and set laser state to 1

    At the moment every time a laser spawns its state is 2 (default). You have the set state of the laser action under the change ship state event, this is before a laser has been spawned so will not affect anything.

  • is correct.. like i said. put on your stop animation in start of layout. then try this

    Start layout > stop ship animation

    stop laser animation

    .....

    Espace is down

    sub-event under espace is down

    ship = red then spawn red laser

    sub-event under espace is down (again)

    ship = blue then spawn blue laser

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • BLBLBLBL Working perfectly, thanks guys love u <3

    EDIT : Just wondering, is there a way to put the same control to do the thing. Here i'm using shift + ctrl because using only ctrl is bugging (idk why, it can change only once). It's just to optimize the gameplay, not necessarly at all but it could be nice to fix it

    capx link : drive.google.com/open?id=0B6phdwDtsxJkTXN1RnU3TUYyMDA

  • Fixed the first part (with boolean/shoot and stuff, perfectly working.)

    But, I still have a problem with the scoring. I've tried the else stuff and it's very complicated and I don't understand.

    So i've found an other way to do it. I've added variable named state into my laser and my asteroid. So when i want to score I compare the state of the asteroid and laser.

    So, if laser.state = asteroid.state then it adds +2 ; if it's not equal it adds +1. The +1 thing is working but not the +2.

    The good things is, I know why but I doesn't know how to fix it. When I press "shift" or "ctrl" to set the red/blue color to my ship it is supposed to change the animation of my laser and change the color, it works, but in the same event it's supposed to also change the state of my variable (putting 0 or 1 dependings of the ship color) but it's just never change and I don't get why. :/

    There is a screen of my even sheet and my capx there : drive.google.com/open?id=0B6phdwDtsxJkTXN1RnU3TUYyMDA

    I just tried it out and I got +2 when my ship was red and I destroyed a red asteroid and if my ship was blue when I destroyed a blue asteroid. Did you get it working?

  • Yeah you have the last version on the link so it's the version with no bug :p.

    But like i've said, i'm wondering if it's possible to do that : (Suppr the shift control and change the ship with just ctrl)

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