New-Gen Living in Obscurity...

Joined: 08 Apr 2009 Posts: 13 Location: South Africa, Pretoria
|
Posted: Wed May 13, 2009 3:20 am Post subject: Key presses and animation |
|
|
I'm trying to make an animation with back drops.
In this case I've got a press any key menu type thing that says the name of the game and under it, press any key.
This is two backdrops with the 'press any key' being a different shade from each other so it gives the appearence that the word is blinking.
What I want the code to do is to go from backdrop1 to backdrop2 and back again when [any key] is not being pressed and when [any key] is pressed it goes to to the 1st map.
I know this may be a simple thing to solve but I've been trying and trying and just can't get it right.
What ive got so far is that I used a while loop and it shows the first backdrop but does not alternate to the other and back again. If [any key] is pressed it just goes onto the map.
One time when I was figiting with the code it made that the word blinked when I held down [any key] and stopped when I let go of [any key]...also strangly, the Esc button took me to the 1st map.
Any help on how I could get this right? _________________
 |
|
Camdog
Joined: 08 Aug 2003 Posts: 606
|
Posted: Wed May 13, 2009 8:21 am Post subject: |
|
|
It sounds like the problem here stems from the fact that you're waiting for two different things at the same time (a key press to advance, or a certain amount of time to flip the backdrops). I'd bypass this problem entirely by using timers:
Code: | plotscript, menu flashy thing, begin
#do whatever needs doing leading up to the menu
set timer(1, 1, speed, @menu flip 1)
wait for key(any key)
stop timer(1)
#do whatever cleanup needs doing
end
plotscript, menu flip 1, begin
show backdrop(1)
set timer(1, 1, speed, @menu flip 2)
end
plotscript, menu flip 2, begin
show backdrop(2)
set timer(1, 1, speed, @menu flip 1)
end |
The speed variable in the set timer commands above determine how quickly your menu flashes. Replace it with a number or a global variable.
In the future, it's helpful to post the code you're having problems with, so we can see exactly what you're doing. |
|