Jump to content

Scrolling an image, without white flashes


Adam1213
 Share

Recommended Posts

When I move by background image it continually flashes white as it renders. The need to do it properly is for a game, that I have started working on and this is happening in.

For my game Scrollable GUI's solves my problem however a solution to this would still be useful but is not required (by me at least)

Basic image scrolling

#include <GUIConstants.au3>

global $multiply=10

Opt("GUIOnEventMode", 1)
global $MAP_width=1000
global $MAP_x=0
global $width=500
global $direction=1; 1 = right  -    0=left

$GUI=GUICreate('Image scrolling', $width, 320)
$gui_bg=GUICtrlCreatePic ('background.jpg', 0, 0, 1000, 320)

GUISetOnEvent($GUI_EVENT_CLOSE, 'quit')
GUISetState(@SW_SHOW)

while 1
    if $direction then
        $MAP_x+=$multiply
        if $MAP_x>$MAP_width-$width then
            $direction=0
            $MAP_x-=$multiply*2
        endif
    else
        $MAP_x-=$multiply
        if $MAP_x<0 then
            $direction=1
            $MAP_x+=$multiply*2
        endif
    endif
    GUICtrlSetPos($gui_bg, -$MAP_x, 0)
    tooltip($MAP_x, 0,0,'Position')
    sleep(100)
wend

func quit()
    exit
endfunc

Edited by Adam1213
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...