I've just added OnBack support to Diddy such that it has the same exception-handling as the other On<Event> methods, and calls Screen.Back().
By default, OnBack() does nothing (preventing your app from closing on the back button). To make it do something, you will need to set the screen.backScreenName field to the name of whichever screen to want to fade to. Setting it to "exit" will end the program.
Global fooScreen:FooScreen = New FooScreen
Global barScreen:BarScreen = New BarScreen
Class FooScreen Extends Screen
Method New()
name = "foo"
backScreenName = "exit"
End
Method Render:Void()
End
Method Update:Void()
If KeyHit(KEY_ESCAPE) Then
Self.Back()
ElseIf KeyHit(KEY_SPACE) Then
FadeToScreen(barScreen)
End
End
End
Class BarScreen Extends Screen
Method New()
name = "bar"
backScreenName = "foo"
End
Method Render:Void()
End
Method Update:Void()
If KeyHit(KEY_ESCAPE) Then Self.Back()
End
End If your game catches the escape key to fade to the previous screen, you may want to change it to call Self.Back() instead. This will give your escape key the same functionality as pressing the back button.
|