Platforms to show: All Mac Windows Linux Cross-Platform

/Util/Resplugin Examples/Game Switch


Required plugins for this example: MBS Util Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Resplugin Examples/Game Switch

This example is the version from Sun, 17th Mar 2012.

Project "Game Switch.xojo_binary_project"
Class GameWindow Inherits Window
Control About Inherits Label
ControlInstance About Inherits Label
End Control
Control Copyright Inherits Label
ControlInstance Copyright Inherits Label
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
EventHandler Sub EnableMenuItems() FileQuit.Enabled = True End EventHandler
EventHandler Sub Open() // Adjust size and show window Left = (App.dis.Width - 640) / 2 Top = (App.dis.Height - 480) / 2 Width = 640 Height = 480 Show End EventHandler
Function FileQuit() As Boolean Quit End Function
Sub StartGame() End Sub
End Class
MenuBar Menu
MenuItem UntitledMenu1 = ""
MenuItem UntitledMenu0 = "File"
MenuItem FileQuit = "Quit"
End MenuBar
Class App Inherits Application
EventHandler Sub Close() if dis<>nil then // Fade gamma out in 500 ticks dis.FadeGammaTo(0, RGB(0, 0, 0), 500) // Set old resolution If saveRes.Switch = False Then Beep // An error occurred End If // Hide windows win.win.Hide win.Hide // Fade back dis.FadeGammaTo(1000, RGB(0, 0, 0), 500) end if End EventHandler
EventHandler Sub Open() dim safe as boolean if not ResolutionLibraryPresentMBS then msgBox "The library RezLib was not found. Please place this library into the Realbasic or after compiling into your application folder." end if 'Get the display on which to operate dis = GetDisplayMBS(0) // Fade gamma out in 500 ticks dis.FadeGammaTo(0, RGB(0, 0, 0), 500) safe=not targetcarbon // on Mac OS X all modes are unsafe // Save old resolution and set new one saveRes = dis.GetCurrentResolution() If dis.SwitchTo(640, 480, 8, safe) = False Then // Fade back, beep and quit dis.FadeGammaTo(1000, RGB(0, 0, 0), 500) Beep Quit End If // Show window win = New BlackWindow End EventHandler
Property dis As DisplayMBS
Property saveRes As ResolutionMBS
Property win As BlackWindow
End Class
Class BlackWindow Inherits Window
Control StartTimer Inherits Timer
ControlInstance StartTimer Inherits Timer
EventHandler Sub Action() // Fade gamma in in 500 ticks app.dis.FadeGammaTo(1000, RGB(0, 0, 0), 500) End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open() // Adjust size and show window Left = 0 Top = 0 Width = App.dis.Width Height = App.dis.Height Show // Open game window win = new GameWindow End EventHandler
Property win As GameWindow
End Class
End Project

See also:

The items on this page are in the following plugins: MBS Util Plugin.


The biggest plugin in space...