PureBasic 6.21 (x86 / x64)
I'm not sure if this is related to another Bug Report I posted: Include 2D Sprites Within a 3D Environment.
The following example demonstrates a 2D sprite, but after the screen is closed the auto stretch parameter is ignored.
• Also noticed that ReleaseMouse(#True) no longer works; custom cursor appears frozen.
1. Maximize window to see the auto stretch parameter in action.
2. Press the Spacebar to:
• Close the screen.
• Open new screen.
• Create sprite.
3. Maximize window to see the auto stretch parameter ignored.
Code: Select all
Enumeration
#MainWindow
EndEnumeration
InitSprite() : InitKeyboard()
WindowWidth = 600 : WindowHeight = 600
nFlags = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered | #PB_Window_Invisible
If OpenWindow(#MainWindow, 0, 0, WindowWidth, WindowHeight, "Press Spacebar to Close / Open New Screen", nFlags)
SetWindowColor(#MainWindow, RGB(0, 0, 0))
WindowBounds(#MainWindow, WindowWidth, WindowHeight, #PB_Default, #PB_Default)
If OpenWindowedScreen(WindowID(#MainWindow), 0, 0, WindowWidth, WindowHeight, #True, 0, 0)
SetFrameRate(60) : SpriteQuality(#PB_Sprite_BilinearFiltering)
CreateSprite(0, 20, 20, #PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
direction = 2
HideWindow(#MainWindow, #False)
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
Select EventWindow()
Case #MainWindow : Break 2
EndSelect
EndSelect
Until Not Event
FlipBuffers() : ClearScreen($000000) : ExamineKeyboard()
If KeyboardReleased(#PB_Key_Space)
CloseScreen()
OpenWindowedScreen(WindowID(#MainWindow), 0, 0, WindowWidth, WindowHeight, #True, 0, 0)
SetFrameRate(60) : SpriteQuality(#PB_Sprite_BilinearFiltering)
CreateSprite(0, 20, 20, #PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
EndIf
If KeyboardReleased(#PB_Key_Escape) : Break : EndIf
DisplayTransparentSprite(0, x, x)
x + direction
If x > WindowWidth - 20 : direction = -2 : EndIf
If x < 0 : direction = 2 : EndIf
ForEver
EndIf
EndIf