About Monkey 2 › Forums › Monkey 2 Programming Help › Screen Fading with Pyro
This topic contains 2 replies, has 2 voices, and was last updated by
Amon
1 year, 1 month ago.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
February 24, 2018 at 12:41 am #13700
Can we get screenfades with pyro scene switching?
February 24, 2018 at 1:37 am #13707I did something like this when I was trying Pyro:
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152Class MyScreen Extends ScreenConst NOT_FADING:Int = 0Const FADE_IN:Int = 1Const FADE_OUT:Int = 2Const FADE_SPEED:Float = 0.05Field fadeValue:Float = 0Field fading:Int = NOT_FADINGField nextScreen:MyScreenMethod SetScreen()self.Set()Self.fading = MyScreen.FADE_INSelf.fadeValue = 0EndMethod OnPostRender( canvas:Canvas ) OverrideIf fading > NOT_FADINGDrawFader( canvas, fadeValue )EndEndMethod FadeToScreen(screen:MyScreen)nextScreen = screenfading = FADE_OUTEndMethod UpdateScreenFade()If fading > NOT_FADINGIf fading = FADE_INIf fadeValue < 1fadeValue += FADE_SPEEDElsefadeValue = 1.0fading = NOT_FADINGEndifElseIf fadeValue > 0fadeValue -= FADE_SPEEDElsefadeValue = 0nextScreen.SetScreen()fading = NOT_FADINGEndEndEndEndMethod OnUpdate() OverrideUpdateScreenFade()EndEndThe using Pyro’s screenmanager:
Monkey1234567891011121314151617181920Class NightOfTheUnfed Extends ScreenManagerMethod New(title:String, width:Int, height:Int, flags:WindowFlags = WindowFlags.Resizable)Super.New(title, width, height, flags)ClearColor=Color.BlackLayout = "letterbox"gameScreen = New GameScreentitleScreen = New TitleScreen' titleScreen.SetScreen()loader=New Loaderloader.Set()loader.FollowUpScreen=titleScreenEndMethod OnMeasure:Vec2i() OverrideReturn virtualResolutionEndEndMonkey1234567891011121314151617181920212223242526272829Class GameScreen Extends MyScreenField camera:CameraField scene:SceneField light:LayerSpriteField atlas:ImageField player:PlayerField layer:Layer'Field maze:MazeField mymap:themapMethod New()EndMethod OnStart() Overridescene = New Scene(ScreenManager)...Method OnUpdate() OverrideSuper.OnUpdate()If Keyboard.KeyHit(Key.Escape)FadeToScreen(titleScreen)EndFebruary 24, 2018 at 2:11 am #13711Thank you, Mr Revills…
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.