Jump to content
Sign in to follow this  
Arfur9

how to stop images flashing as they show and hide

Recommended Posts

Arfur9

I'm trying to do a hidden objects game and I have a problem were for a split second as the image changes I get a white area as the image hides/shows, is there anyway to stop this?

this is the code I'm messing with

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 800, 600, -1, -1)
$img="Backgroundalley.jpg"
$door ="door.jpg"
$dooropen = "dooropen.jpg"
$Pic1 = GUICtrlCreatePic($img, 0, 0, 800, 600)
GUICtrlSetState($Pic1, $GUI_DISABLE)
Local $aSound = _SoundOpen("machineClose.mp3")
$Pic3 = GUICtrlCreatePic($dooropen, 142, 6, 299, 540)
GUICtrlSetTip(-1, "Door")
GUICtrlSetOnEvent(-1, "Pic2Click")
GUICtrlSetState($Pic3,$GUI_HIDE)
$Pic2 = GUICtrlCreatePic($door, 142, 6, 299, 540)
GUICtrlSetTip(-1, "Door")
GUICtrlSetOnEvent(-1, "Pic1Click")
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "mainClose")
While 1
Sleep(100)
WEnd
Func mainClose()
$ExitDialog = MsgBox(36, "Are You Sure?", "Are you sure you want to exit?")
If $ExitDialog = 6 Then

Exit
Else
Return
EndIf
EndFunc ;==>mainClose

Func Pic1Click()
Sleep( 111)
GUICtrlSetState($Pic2, $GUI_HIDE)
GUICtrlSetState($Pic3, $GUI_SHOW)
;_SoundPlay($aSound, 1)
Return
EndFunc
Func Pic2Click()
GUICtrlSetState($Pic3, $GUI_HIDE)
Sleep( 1)
GUICtrlSetState($Pic2, $GUI_SHOW)
;_SoundPlay($aSound, 1)
Return
EndFunc

I've attached the images and file

game.zip

Edited by Arfur9

Share this post


Link to post
Share on other sites
Colyn1337

In your pic1click function try doing the show command before the hide... In your second function you have a sleep(). Even tho you've put "1" there, it's actually going to sleep for 1000.

Hope this helps.

Share this post


Link to post
Share on other sites
czardas

When you create your GUI, try using the Windows style $WS_EX_COMPOSITED. See if that stops the flickering.

Edited by czardas
  • Like 1

Share this post


Link to post
Share on other sites
Arfur9

Thanks czardas that did the trick :)

oh the sleep () was my vain attempt at stopping it amd wasn't really doing anything useful

thanks for the help guys

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×