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.

Newcomers DBPro Corner / Sprite Not Showing Up

Author
Message
Wamphyri
12
Years of Service
User Offline
Joined: 29th Jan 2012
Location:
Posted: 31st Jan 2012 02:29
I entered this code from the Beginners Book and I cant figure out why it doesnt show the sprite. Can someone point me in the right direction.



It compiles fine and gives no errors it just doesnt show the sprite. None of the examples in this chapter do. I can use the code off the source CD and it still doesnt work.
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 31st Jan 2012 07:33
The images you are pointing to must be in the working directory. Remember when using a blank document, default dir is DBPRO's TEMP dir. You may wann add "SET DIR" and the folder caontaining your images. it should have given you an error "image does not exist at line etc." but I've had this error msg fail to appear and the program compile once or twice.

Also try adding "SET CURRENT BITMAP your-bitmap-number" before you "GET IMAGE" and then "SET CURRENT BITMAP 0" and "DELETE BITMAP your-bitmap-number" before you sprite your image.

If that doesn't work - and it may not - use CREATE ANIMATED SPRITE spriteno, filename/path, 1, 1, imageno (check out the help doc for more). I find LOAD BITMAP to be a waste of time. If you need just an image, use LOAD IMAGE. Otherwise I always use this for sprites, even non-animated ones. It's easier and faster.

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 31st Jan 2012 09:35 Edited at: 31st Jan 2012 09:35
Actually, I think you just need an extra sync command at the beginning of your program. So right after you turn the sync on, sync it. To see the difference run this:



and then run this (note the two syncs instead of one):


The first one displays nothing but the second one displays what we expect to see.

Wamphyri
12
Years of Service
User Offline
Joined: 29th Jan 2012
Location:
Posted: 31st Jan 2012 14:03
Actually I got it to work by adding a Do Loop like this and getting rid of the load bitmap and changing it to load image like this


I assume it was because it was only drawing it once until I put it in a loop. Now this code doesn't display the background




But if I change it to load Image... and then paste it in the loop it works like this


It works fine like this is there anything wrong with doing it this way? IF there isn't I'm just assuming it is just better to stay away from load bitmap command and also make sure your display command is in a loop.
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 31st Jan 2012 18:38
Well all games need a main loop where you call functions and labels and draw sprites, so you're on the right track.

-------------------------------------------------------------

Login to post a reply

Server time is: 2024-11-22 06:27:35
Your offset time is: 2024-11-22 06:27:35