Possible 0.9.92 issue? Problem with triggering rules
I hope it is not a stupid mistake on my part, but it seems that .9.92 introduce a change/bug in what/when rules are triggered. I have seen it in several different scenarios but here is a simple one (project file).
http://www.4shared.com/zip/XCbMeBTD/testing.html
This one is a basic page up/down logic - but for some strange reason (or a mistake on my part...) it behave in a very strange way:
1. If I click DOWN and than UP, UP will not work
2. If I click UP and than DOWN, UP will work and DOWN will work, but once I get back to page 1 UP might not work (especially if I clicked on DOWN twice
3. If I click UP several times, DOWN and UP will work until I get to 1 - If I click twice on DOWN when at 1, UP will no longer work.
The rules looks simple, but does not seem to work. I tried several scenarios, this is just one of them.
For some reason I have a feeling it might be a silly mistake on my part. Any assistant will be appreciated!
Thanks!
GR
Follow Eating My Hat on Facebook and the Blog
Check out my templates in the GS Marketplace or at the store
Best Answer
-
POM Posts: 2,599
Hey Gabby ,
The problem is not with triggering rules , the problem is with the "Touch is released"
See , touch is released is not working as one expect it to work , The way you (and the rest of us) expect it to work is that when you press an actor , and then lift your finger up , now trigger the event , AND THEN STOP ! BUT! in real life , the trigger "Touch is released" stays ON up until the point that you press that specific actor again , this fact sometimes causes confusion as to why rules are being triggered again and again even if i did not press that actor and released touch , thats happening mostly when wrapping the "touch is released" rule inside a different rule , say a boolean , and when that boolean goes true , the touch is released inside it triggers again even if you didn't pressed that actor , cause like i said , once you triggered "Released" once , it stays on until you press that actor again (then when you release touch it stays on again;) )
The simplest way to see it with your own eyes is to make an actor , put in it a rule :
When touch is released :
Display text (any text)
Drag it to the scene , and see that once you release touch from that actor , it is displaying text forever (at least until you press it again) , meaning the trigger stays ON .
I hope that makes sense ..
Now that i explained how it works , ill explain whats happening in your project:
when you press "down" you reduce 1 from the value only when the value is more than 1.
Now say the value is 2 , and you press it again , the value is now 1 , and here is when the problem is occurring :
Like we said the value is now 1 , and if you hit the "UP" button , you basically change it to 2
BUT WAIT ! remember we said the "touch is released" stays ON all the time , so what happening now is that the "Down" button triggers !
touch is released is on - ✔
Value more than 1 (its 2)- ✔
It reduces it back to 1 !
All this happening so fast that it looks like a bug !
Now a way to avoid it , and i recommend doing this with ANY touch is release event is to make a boolean ,
when touch is released - change "make event" to TRUE
Now a new rule:
when "self.make event" IS true
Do bla bla bla
Change "self.make event" TO false .
This way it will work the right way !
P.S
Note that if you use integers you can accidentally go to the negatives numbers , therefore , when using events like changing pages , its best to use "index" so that the minimum value is 0 !
Hope it will help youRoy
Answers
GR