|
-
August 15th, 2004, 05:52 AM
#2
Well, lets think about it.
You might have a string that contains...
Code:
char *strTicker = "This is my ticker, here is an image!";
And, according to that string, there is supposed to be an image at the end of it.
Obviously there isnt, so when we scroll this is will just be a string of text, like it is with yours now i assume.
To place the Image at the right place, you firstly need to find out where it needs to be!
If your doing a predefined string, then it's not a problem, you could put '[image]' in your string so you could place it there.
Code:
char *strTicker = "This is my ticker, here is an image![image]";
Like that!
Then, every frame you need to check your string, and get it's X position, because it could be halfway off the screen, and if were still drawing onto the end of where the string USED to be, we'll just have a static image!!
So we get the X position of the string, now we have to get the strings length in pixels...i know DirectX has a function for this in the API, i don't know what your using though...
So now, we have the X position of the Ticker, and the String Pixel length.
Code:
int iXPos, iTickerStrLen;
char *strTicker = "This is my ticker, here is an image![image]";
//Here's the loop
while ( looping )
{
//Get the X position of the string...probably held in a RECT or similar.
//Get the length of the string in pixels, it'll be part of the FONT class you'll use probably.
//Now we have the length of the string in pixels, held in iTickerStrLen
//and we have the position of the scrolling text held in iXPos.
//We now know that if we do a sum....
int iImagePos = ( iXPos + iTickerStrLen );
//We have the position of where the [image] should be.
//Of course, this code only lets you add ONE image, and thats
//at the end, so you'll need to add some string searching code in!!
//But now we have the position....you can run a function that will
//draw your image, at the end of the string, constantly.
//hope this helps...
}
That should be enough to get you off your feet 
Have fun!!
Dean.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|