Help for a total newbie

Get help using Construct 2

Post » Sat Feb 16, 2013 5:54 pm

What events do I set to allow me to change the animation an object is playing back and forth by clicking on it?
B
5
Posts: 29
Reputation: 383

Post » Sat Feb 16, 2013 6:33 pm

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.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Sat Feb 16, 2013 8:01 pm

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?
B
5
Posts: 29
Reputation: 383

Post » Sat Feb 16, 2013 8:35 pm

Your psudo code should work. You have a screenshot we can look at?
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Sat Feb 16, 2013 9:19 pm

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)
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sat Feb 16, 2013 9:31 pm

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?
B
5
Posts: 29
Reputation: 383

Post » Sat Feb 16, 2013 9:40 pm

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.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sat Feb 16, 2013 9:43 pm

"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 :
[code]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"[/code]

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.Kyatric2013-02-16 21:45:59
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sat Feb 16, 2013 9:58 pm

http://www.mediafire.com/view/?46tyd5wpliq2fgx

Is this correct?
B
5
Posts: 29
Reputation: 383

Post » Sat Feb 16, 2013 11:10 pm

Please help
B
5
Posts: 29
Reputation: 383

Next

Return to How do I....?

Who is online

Users browsing this forum: GSquadron, HTB and 25 guests