Recently when I was working on my game's script, I decided that it would be cool if by pressing the control key, then the player could use 'slow motion' for a few seconds. Right now the script slows down the frame rate, and increases the speed of the player sprite. (So everything else moves slow, but the player is only slowed down a little.) It also subtracts your slo-mo power from the internet. What I'm trying to do is have it subtract 1 from the slo-mo power each frame, but right now it subtracts it all at once. I tried the WaitForFrame line, but it didn't seem to work. Is there any way to do this? This is the code I'm using.
Sub Player_OnControllerMove(OldActions, NewActions)
If (Not OldActions) And NewActions And ACTION_BUTTON3 Then DoFireButton5
End Sub
'slow motion'
Sub DoFireButton5()
If ProjectObj.GamePlayer.InvQuantityOwned(7) <= 1 Then Exit Sub
If ProjectObj.GamePlayer.InvQuantityOwned(7) > 1 Then
ProjectObj.GamePlayer.FrameRateLimit = 30
ProjectObj.GamePlayer.rMap.SpriteTemplates("player").MoveSpeed = 5
LoseSloMo
ProjectObj.GamePlayer.FrameRateLimit = 60
ProjectObj.GamePlayer.rMap.SpriteTemplates("player").MoveSpeed = 3
End If
End Sub
Sub LoseSloMo
ProjectObj.GamePlayer.InvQuantityOwned(7) = ProjectObj.GamePlayer.InvQuantityOwned(7) - 1
If ProjectObj.GamePlayer.InvQuantityOwned(7) <= 1 Then Exit Sub
If ProjectObj.GamePlayer.InvQuantityOwned(7) > 1 Then
LoseSloMo
End If
End Sub
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16
Note: Between OnControllerMove and slow motion there is more code for shooting, and other things which are generated by the scripting wizard. Since I don't think they would have any effect on the slow motion, i didn't include them.