Delay probs

This forum is currently in read-only mode.
0 favourites
  • I'm sure everybody already encountered the following problem, but I am the one who has never been able to figure out what to do.

    If, for example, I want a brick (in a brick breaker game) to change from animation 1 to animation 2 when it's hit by the ball once. Then, when the ball hits the brick again, I want the brick to change from animation 2 to animation 3. And so on.

    But, there's no delay or anything, so the brick changes from the first animation to the last animation when it's hit once. VERY annoying.

    And then, when I'm just about to go see my psychologist, the Construct devs release a new version with the so cool wait object!

    ...But even with it, I still have problems. Depending where I put the "wait for 10 ms" condition/action, I got either all the instances of a same object to be affected when one of them is hit, either the same problem which leads the brick to go to its very final phase when it's hit only one time.

    CAP file (problem located in the events of the ''Hit Bricks'' group) : http://butor.com/resource.do?uid=1292198866697

    Please help me...

  • Salut !

    It will work if you reverse the order of the events.

    i removed the wait object and rearranged the events like this instead :

    + Balle: On collision between Balle and BricBrique
          + BricBrique: Pick closest to: Balle.X, Balle.Y
                + BricBrique: Animation "5" is playing
                         -> System: Add 1 to global variable 'briques'
                         -> BricBrique: Destroy
                + BricBrique: Animation "4" is playing
                         -> BricBrique: Set animation to "5"
                + BricBrique: Animation "3" is playing
                         -> BricBrique: Set animation to "4"
                + BricBrique: Animation "2" is playing
                         -> BricBrique: Set animation to "3"
                + BricBrique: Animation "1" is playing
                         -> BricBrique: Set animation to "2"
                + BricBrique: Animation "0" is playing
                         -> BricBrique: Set animation to "1"
    [/code:3umkpfdo]
    
    Indented "+" events are sub-events.
    
    it seemes to work ok... edit : but someone may know a better way (surely, i ain't a programmer lol)
  • Erm, i noticed a bit late that your animations used numbers as names....

    So you can just set a private variable (hitme = 0) and increment it :

    + Balle: On collision between Balle and BricBrique
        + BricBrique: Pick closest to: Balle.X, Balle.Y
        + BricBrique: Value 'hitme' Less or equal 5
            -> BricBrique: Add 1 to 'hitme'
            -> BricBrique: Set animation to BricBrique.Value('hitme')
        + System: Else
        + BricBrique: Value 'hitme' Greater than 5
            -> System: Add 1 to global variable 'briques'
            -> BricBrique: Destroy[/code:1dkfn2fp]
    
    And probably you could use families too, that could save you a lot of events...
  • Hey, toi aussi t'es francophone?

    'Til now it works! Thanks a bunch!

    ...I didn't know 'pick closest' condition...

    Though, I don't see how I could use families. Since there are three kinds of brick, and that each of them is destroyed after a different number of hits, I think it'd be hard to get family events to work properly. :-/

  • [quote:29r6cd7w]Hey, toi aussi t'es francophone?

    De la t?te aux pieds!

    [quote:29r6cd7w]'Til now it works! Thanks a bunch!

    ...I didn't know 'pick closest' condition...

    Heh, that's cool You got a hell lot of events in there, though !

    And it wasn't working because, you wrote them in order '1,2,3...", and from what i've read around here, events are executed one after the other. In your case, 0 was true, so you switch animation to 1. But then the next event (animation is 1) is true too, so it switches to anim 2, and so on... I've seen a similar case around the forums here So all you have to do is reverse the events...

    [quote:29r6cd7w]Though, I don't see how I could use families. Since there are three kinds of brick, and that each of them is destroyed after a different number of hits, I think it'd be hard to get family events to work properly. :-/

    Actually, i don't know either Haven't tried it in your game. It's probably OK the way it is now, as long as it works, it's ok I guess XD

  • C'est quand m�me dr�le de penser qu'on parle toujours en anglais pour �tre s�rs que les autres comprennent!

    The events order things is weird, but anyway, if it works I won't complain.

    Thank you for helping!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Je pense que c'est normal.

    If everyone here were writing in their native tongue, how could we help each other out?

    [quote:202yr8mi]

    The events order things is weird, but anyway, if it works I won't complain.

    It's true it appears more logical to put them in numerical order. But then, like i said, all conditions will be true, one after the other. But on screen, you will only see the last result : the brick disappears, because all actions are performed ultra fast. Like superman reading a book xD

    [quote:202yr8mi]Thank you for helping!

    NP, it helps me to learn Construct too

  • The events order things is weird, but anyway, if it works I won't complain.

    Je comprend si tu parle en francais, mais stell dir mal vor ich w?rde die ganze Zeit deutsch reden

    To understand what really happens, and why the event order is so important, you may want to have a look at this thread: Introduction to branching

    Another way to do it without reversing the order is using "else" (see the thread above)

    + BricBrique: Animation "0" is playing
                         -> BricBrique: Set animation to "1"
    + Else
    + BricBrique: Animation "1" is playing
                         -> BricBrique: Set animation to "2"
    + Else
    + BricBrique: Animation "2" is playing
                         -> BricBrique: Set animation to "3"
    ...
    etc
    [/code:3vmp428i]
  • [quote:35qgu5o8]stell dir mal vor ich w?rde die ganze Zeit deutsch reden

    Essayez d'imaginer si je parlais allemand tout le temps

    Thanks Google hehe

    I used Else here too :

      + Balle: On collision between Balle and BricBrique
            + BricBrique: Pick closest to: Balle.X, Balle.Y
            + BricBrique: Value 'hitme' Less or equal 5
                -> BricBrique: Add 1 to 'hitme'
                -> BricBrique: Set animation to BricBrique.Value('hitme')
            + System: Else
            + BricBrique: Value 'hitme' Greater than 5   <== EDIT : i think this line can be removed
                -> System: Add 1 to global variable 'briques'
                -> BricBrique: Destroy[/code:35qgu5o8]
    
    Anything wrong with it? I just wanna know if i can improve this. I like to keep the code very short, if possible.
  • I used Else here too :

      + Balle: On collision between Balle and BricBrique
            + BricBrique: Pick closest to: Balle.X, Balle.Y
            + BricBrique: Value 'hitme' Less or equal 5
                -> BricBrique: Add 1 to 'hitme'
                -> BricBrique: Set animation to BricBrique.Value('hitme')
            + System: Else
            + BricBrique: Value 'hitme' Greater than 5   <== EDIT : i think this line can be removed
                -> System: Add 1 to global variable 'briques'
                -> BricBrique: Destroy[/code:3adycjmx]
    
    Anything wrong with it? I just wanna know if i can improve this. I like to keep the code very short, if possible.
    

    Oh, I'm sorry, I overread this. You are right with your edit. That line can be removed. Nice improvement of the code

  • Ok thanks

  • It's cool to be called Kan. People do never call me like that though I want them to do so!

    The thing is I have another pseudo somewhere else, plus a few actual names so...

    Well, anyway.

    I continued with the first way (pick closest and reverse events order) and the game's been released.

    I guess I'll let you have it : http://butor.com/resource.do?uid=1292646405489

    Go Construct go!

    Kan

  • [quote:2h9o54hz]It's cool to be called Kan. People do never call me like that though I want them to do so!

    It's the only name i know you by...

    I tried the game, and it's nice, but i really suck at playing it... xD

    That tiny ball got me all "WTF"!

  • Lol. Of course. What else but Kan?

    I can't do anything if you suck at playing it ).

  • Yup, that's what i was talking about.

    I never played much breakout style games...

    Are you working on something else now?

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