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 / help with using a sprite to display text

Author
Message
ThatOther Person
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location:
Posted: 15th Sep 2009 10:55
does anyone know why this function isn't working?



The variable textsprite is the sprite I'm using for the text. Its a 65 frame animated sprite with each frame containing a different character. Right now Everything works as should except that each character is displayed as a 0 (the first frame of the sprite). So for example if I do printspritetext(20,20,"testing123"); then ten zeros print onto the screen rather then the text that should be shown.
Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 16th Sep 2009 00:42
I dont know much but it looks to me that if you put 0 into the sting you are telling it to load frame 0 which doesn't exist. I may be wrong but attempt to use 0 in your string to see what happens. If that is the case just add 1 to all the textnumbers...

Also the snippet here doesnt compile, there is a variable called textsprite that isn't defined which I can only assume represents the sprite that isn't uploaded making it difficult for at least me to debug in my vc++ unless I'm stupid...

EYE R T3H +ick +ack +oe mester
ThatOther Person
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location:
Posted: 16th Sep 2009 01:12 Edited at: 18th Sep 2009 16:00
Sorry I didn't really think of fixing up the snippet to get it to compile on its own (its just the relevant part cut out from the game). Like I said yeah textsprite represents the sprite I was talking about. Your right I hadn't realized it but well it wasn't the cause of the problem all of the numbers where off by one so I fixed that. Here it is again. It should compile fine like this and I attached the image file.



EDIT: I got it working. For any future people stuck on the same thing here is the functional version of the function.



Attachments

Login to view attachments
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 21st Sep 2009 20:26
You don't need to use left/right functions to cut off one character from a string, you can index the string as an array (it is an array of characters, after all). Also, string comparison is slow and it forces you to write a separate line for each index. You can use character comparison, but it's even better to consider that a character is stored with its ASCII code which is a number. The following code should do the same as the function above but it's much shorter:

Login to post a reply

Server time is: 2024-11-20 15:36:24
Your offset time is: 2024-11-20 15:36:24