Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Mouse Rollover Program

Years of Service
User Offline
Joined: 26th Apr 2012
Posted: 27th Apr 2012 04:33
So I am having an issue creating a program where the user takes their mouse and runs it over an image, which causes the program to output a second image to the screen. Then if the user moves the mouse away from the new image the program will output the original image again.

I have the dbMouse(); in the program but I am pretty sure I am not utilizing it correctly haha.

Currently my if statement parameters were just me doing try and error to see if anything was working as far as the if/else statement was concerned. With that being said, here is what I am currently working with so far... any guidance on what I am doing wrong or where to go with this program would be greatly appreciated.

Years of Service
User Offline
Joined: 5th Dec 2009
Posted: 27th Apr 2012 22:02
There are several problems with your program.
First, if you want to show sprites, you need to put dbSync() somewhere in your loop-- which you are also missing (the loop).
Second, dbWaitKey() will pause the program waiting for a key stroke--moving the mouse will not affect anything until you press a key on the keyboard (to allow the program to progress).
Third, check the conditions for changing the sprite that is displayed:
You want to display only one image (sprite) at a time?
your sprites are set to the same coordinates (0,0). This will cause the condition to ALWAYS be true

I think you want something like this:
You need to first declare the image locations to where you want them to be displayed. Declare the image to sprite association:
Now you start your loop.

The fastest code is the code never written.

Login to post a reply

Server time is: 2020-02-26 07:42:32
Your offset time is: 2020-02-26 07:42:32