TOUR
PRICING
HELP
Stencylpedia
Blocks Guide
Sample Games
Developer Center
FORUMS
CHAT
#MADEINSTENCYL
EDUCATION
SIGN IN
×
Welcome back!
Username or E-mail
Password
(
Forgot?
)
C
OMMUNITY
Home
Issue Tracker
Inbox [0]
New Posts
New Replies
Search
Stencyl Community
→
Stencyl
→
Ask a Question
→
Creating an event that doesnt spam at a specific value
Pages:
1
Creating an event that doesnt spam at a specific value
xandramas
Posts: 411
January 17, 2013, 06:03:26 pm
how do i create an action to happen only once when a players hp hits a specific number.
Like 10 but only happen once when the hp is sitting on 10. I'm trying to create an explosion effect to happen once at 10 hp and turn off until hp hits 10 again after healed or damaged
Check my profile to test my games in development.
Asterite Saga:
http://www.facebook.com/XGameLabs
Next Game in development.
Hectate
Posts: 4643
January 17, 2013, 06:14:06 pm
Use a boolean that starts false but gets set to true right after the event happens - it will happen once and then stop happening since the conditional that checks the boolean has changed.
For bonus points you could reset the boolean at a later time to allow it to happen again (so for instance if you wanted the explosion effect to happen again later, but no sooner than a minute after the last one just change it back again with a Do after 60 seconds block).
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.
xandramas
Posts: 411
January 17, 2013, 07:16:00 pm
that looks good but the problem that I am having is when the event is constantly triggered. Like when the player is sitting on 10 hp it'l keep triggering the event that happens at 10 hp instead of triggering only once.
What im trying to do is when a player's health hits or passes 10. To create an explosion effect. But if the player is on 10 hp for some reason I dont want it to keep creating that effect.
Check my profile to test my games in development.
Asterite Saga:
http://www.facebook.com/XGameLabs
Next Game in development.
Tuo
Posts: 2469
January 17, 2013, 07:22:46 pm
Try this idea (Explosion is a boolean, default = false), an extension of hectate's idea:
If HP = 10
If < Not < Explosion > >
Set Explosion to True
[Explosion coding]
If player collides with an actor
Set Explosion to False
[Change HP accordingly]
Don't look to me but rather to the One who is the reason for what I do.
If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.
If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (
http://community.stencyl.com/index.php/topic,16160.0.html
)
xandramas
Posts: 411
January 18, 2013, 03:25:33 am
i'll try that out, thanks,
Check my profile to test my games in development.
Asterite Saga:
http://www.facebook.com/XGameLabs
Next Game in development.
Unept
Posts: 351
January 18, 2013, 02:35:54 pm
Let me know how these suggestions work for you. I've been having a lot of trouble with this. I believe it's because I rely too much on the Always event, and less on the other events like boolean, comparison, etc. Still trying to figure it out.
Unicycle Hero:
iOS
| Level With Me:
iOS
/
Android
| Hue Ball:
iOS
/
Android
| Lava Bird:
iOS
/
Android
|
Disposabot
|
Twitter
comport9
Posts: 51
January 18, 2013, 02:57:29 pm
The boolean "trick" works simply.
if hp==10 & boolean == False
Do Stuff
boolean = True
Then it'll only run once.
Pages:
1