Support => NGUI 3 Support => Topic started by: silversteez on November 20, 2012, 03:46:48 PM
Title: new press event on state change...
Post by: silversteez on November 20, 2012, 03:46:48 PM
hey guys,
i have an eventListenPressed on a sprite. let's say i have two game states, one in which presses are allowed (STATE_CAN_PRESS) and one in which presses are not allowed (STATE_CAN_NOT_PRESS). i'd like the user to be able to press the sprite during STATE_CAN_NOT_PRESS and as soon as the state changes to STATE_CAN_PRESS the press event will register.
anyone know a good way to achieve this? perhaps a way to make currentTouch into a new touch when the state changes...
Title: Re: new press event on state change...
Post by: ArenMook on November 20, 2012, 03:51:11 PM
Eh? You are the one that will write this script, so you can keep it simple:
void OnPress (bool isPressed)
{
if(canPress && isPressed)<do stuff>;
}
Setting the sprite is equally trivial: sprite.spriteName = "Sprite Name";
Title: Re: new press event on state change...
Post by: silversteez on November 20, 2012, 05:29:36 PM
in your example, OnPress only fires once when the user first presses. if the user is holding their finger down on the sprite when canPress becomes true, <do stuff> will not occur. the user will have to lift their finger and press again.
i guess what i'm looking for is more of an update function that runs while a sprite is pressed. like WhilePressing() rather than OnPress().
Title: Re: new press event on state change...
Post by: ArenMook on November 20, 2012, 05:57:06 PM
Then you need to add an Update() function that will check for that logic. :P