Help for a total newbie

  • What events do I set to allow me to change the animation an object is playing back and forth by clicking on it?

  • Use the mouse object and it should give you click events to use. Then you use the set animation event.

    I highly recomend reading the manual and doing some tutorials.

  • Here's my exact issue though- these are the events i have set:

    -> On left button clicked on WPawn

    -> Is animation "Unselected" playing

    Action: WPawn- Set animation to "Selected" (play from beginning)

    -> On left button clicked on WPawn

    -> Is animation "Selected" playing

    Action: WPawn- Set animation to "Unselected" (play from beginning)

    But when i run my layout, i can "select" my WPawn by clicking on it, but clicking on it again doesn't unselect. Why?

  • Your psudo code should work. You have a screenshot we can look at?

  • Nah that won't work because your second event will undo the first one. If it's the "unselected" animation playing and you click - the first event will set it to "selected" and then second event will set it back to "unselected". Try it like this instead:

    On left button clicked on WPawn

    ---Is animation "Unselected" playing

    ------Action: WPawn- Set animation to "Selected" (play from beginning)

    ---Else

    ------Action: WPawn- Set animation to "Unselected" (play from beginning)

  • But Else can only follow non-triggered events I thought?

    And also what if i reversed the order? So first Selected->Unselected, then Unselected->Selected?

  • The Else follows the 'Is animation playing'. They're both sub-events of 'on clicked'.

    Reversing the order will have the same problem when trying to unselect. The second event would set it back to selected.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Is animation playing" is not a triggered event, it's a "state" checked every tick.

    Also the pseudo code ramones gave is executed like this :

    User click on a WPawn
    1 => If WPawn is playing "Unselected" animation
    1 ..=> Set the animation to "Selected"
    2 => Else (if WPawn is NOT playing "Unselected", so is playing "Selected" in this binary setup)
    2 ..=> Set the animation to "Unselected"

    Else will execute only if the previous event hasn't executed.

    If 1 is checked and found to be true, 2 won't be executed at all.

    If 1 is checked and found to be false, 1 won't be executed and so 2 is executed.

    (That's inherent to how events work)

    On one click, there can only be one state and one state switch with this code.

  • mediafire.com/view

    Is this correct?

  • Please help

  • Yeah that looks right.. is it not working?

  • Nope... I can Select the WPawn when i run the layout, but not unselect... Is it something with my animations? I have "Selected" and "Unselected" as the two animations, and they each only have 1 frame.

  • Please someone help!

  • Anyone?...

  • YAYYYYYYY it's working now!!! I didn't change anything, just tried it again a few hours later and it worked. The code works then! I don't understand why the code didnt work earlier though... There must be a major lag between the changes you make in the program and when it actually takes effect when you run the layout.

    Thanks to those who helped, sorry i suck at this D:

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