Setting button States with Touched and MouseOver

31 views
Skip to first unread message

Jacques Leemans

unread,
Aug 22, 2012, 5:21:33 PM8/22/12
to c2-deve...@googlegroups.com
When creating buttons, add the frames in reverse order.

Frame0 = MouseOver/Touched state first
Frame1 = Button Normal state.

With Startup, set all the buttons to frame 1

If MouseOver button
Set animation frame speed to 24
Start Animation from start.

If Button Touched
Set animation frame speed to 0.5
Start Animation from start.

This way you can use the build in animation system to handle the button states for you, without setting the button's to a frame every tick, or Inverted MouseOver, or waits, etc...

NOTE: Loop must be set to off!

Miha Petelin

unread,
Aug 23, 2012, 4:54:13 AM8/23/12
to c2-deve...@googlegroups.com
I just do it this way:

> If Button touched
> Set animation frame to 1
> System: wait 1 second
> Set animation frame to 0

And if it is a toggle button...

> if Button touched
> set animation frame to 1 - Self.AnimationFrame

2012/8/22 Jacques Leemans <jjle...@gmail.com>:
> --
>
>

Miha Petelin

unread,
Aug 23, 2012, 4:55:22 AM8/23/12
to c2-deve...@googlegroups.com
Oh yeah, include the "trigger once while true" condtion as "button
touched" condition keeps running as long as the finger is down, which
can be quite a few ticks.

2012/8/23 Miha Petelin <mih...@gmail.com>:

Jacques Leemans

unread,
Aug 23, 2012, 4:55:50 AM8/23/12
to c2-deve...@googlegroups.com
Wait 1 sec isn't the same on all browsers/devices...

--



Miha Petelin

unread,
Aug 23, 2012, 5:00:38 AM8/23/12
to c2-deve...@googlegroups.com
In most cases, it is good enough. It is just a visual feedback that
doesn't influence the gameplay.

2012/8/23 Jacques Leemans <jjle...@gmail.com>:
> --
>
>

Jacques Leemans

unread,
Aug 23, 2012, 5:08:11 AM8/23/12
to c2-deve...@googlegroups.com
We have had a few issues where you can't see which button was touched on the ipad, cause the dev used your technique. It does influence user experience.

--



benwardohs

unread,
Aug 23, 2012, 2:54:41 PM8/23/12
to c2-deve...@googlegroups.com
Useful trick, I didn't think of using the animation system as a platform-friendly timer. I'll have to start using this over the Wait command.

marc

unread,
Aug 23, 2012, 3:08:32 PM8/23/12
to c2-deve...@googlegroups.com
This seems like it will work well if we have one sprite per button, what if we want to have one sprite to be used for all the buttons? I like to use one sprite for as much as I can. 

We could have multiple animations in the sprite and set the animation per-button on startup. Have you used it this way? I think I might try this.. 

Jacques Leemans

unread,
Aug 23, 2012, 4:02:40 PM8/23/12
to c2-deve...@googlegroups.com
@Marc, the buttons are instances of the same Sprite (btnNumbers) each one has a different value for a var, lets call it num, so you have buttons 0 - 9, and they're animations are set to the value of num (On start). Then you just use the frames to set touched/normal, like mentioned above.
Message has been deleted

marc

unread,
Aug 23, 2012, 5:01:24 PM8/23/12
to c2-deve...@googlegroups.com
@Jacques

Excuse me for being dense, but are all the animations the same for all the buttons? Just two frames, like you described earlier? 

I generally put buttons of all types in one sprite and sort them with a type variable. So I will have graphics for my exit, ok, etc. buttons in the one animation. So I am still thinking your technique will work if I split up multiple animations in the sprite per button and set those at startup too. 

Thanks
Reply all
Reply to author
Forward
0 new messages