Problem with amination frame

Get help using Construct 2

Post » Wed Feb 22, 2017 4:50 pm

Not sure if i understand that 'code'.

Everything under 'on start layout' runs once, and on startup.

So, if you want the animation frame to reflect the initial state of the global trailOnOff .. then just ..

Global variable trailOnOff = 1 or 0 (whatever you choose)

On start layout
______________set animationframe to trailOnOff

Still assuming that there is only 1 trailbutton and 1 trail.
If not, things got to be picked. You dont do that now.

I dont see how the keypress will not work. Unless you have some 'thing' in the rest of the code.
Posts: 2,493
Reputation: 20,950

Post » Wed Feb 22, 2017 4:52 pm

resdesign wrote:I still have a problem though the code is definitely better. Basically the button works only on one of the event (the rest works)
The reason I need both is because some students will use only the keyboard and some students will use touch or mouse. I used mouse in the example but of course I could replace with touch which would also both mouse and tap.

case 1:
on start layout set trailOnOff = 1
on trailONoff = 0/ set animation frame to 0
else/ set animation frame to 1
result: keyPress changes the button - mouse does not
case 2:
on start layout set trailOnOff = 1
on trailONoff = 0/ set animation frame to 1
else/ set animation frame to 0

result: keyPress does not change the button - mouse does

I will take a look at it but my suggestion for education uses is to have the user select mouse or touch before starting play to eliminate that problem and you will have just one trigger variable to tell the events to use either mouse or touch.

I do that in my games to avoid confusion and getting clicks and taps at the same time.
Banned User
Posts: 1,229
Reputation: 34,790

Post » Fri Feb 24, 2017 2:13 pm

Can anyone help on this one.?
Something strange happens :
If I start with the mouse event, the button do not switch. However if I start with the T key (which is working) and then proceed to use the mouse it switches. So it seems that the trigger for the mouse event when chosen first is not firing properly.

Note: the only reason I am doing both events is that specs for education covers all kind of special needs. Most students will use the mouse or tap events while some will use the keyboard.
Posts: 86
Reputation: 618

Post » Fri Feb 24, 2017 3:22 pm

OK. I feel very embarrassed. It actually works. The reason I thought it did not work is because I forgot to set the speed of the animation button to 0.
Posts: 86
Reputation: 618


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 56 guests