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 AppGameKit Corner / Draw Text On A Sprite And Make A New Sprite With Image+Text?

Author
Message
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 29th Dec 2017 15:44
Hi,

Started work on a new Android / HTML5 word game.
Would it be possible to draw text on a sprite and make a new sprite with image+text?
Let us know, thanks!

JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 29th Dec 2017 20:54 Edited at: 29th Dec 2017 20:55
Take a look at
https://www.appgamekit.com/documentation/Reference/Image/CreateRenderImage.htm
https://www.appgamekit.com/documentation/Reference/Core/SetRenderToImage.htm

You can render the text and a sprite to a render image.....then you use the render image on a new sprite which has the sprite plus the text on it. This works on windows fine but not sure if you might have problems on html5.
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 30th Dec 2017 01:44
Thank you, we will try that!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 30th Dec 2017 05:01 Edited at: 30th Dec 2017 05:34
Hi,

I've been fighting this for hours, I can't seem to get it working.
Below is the source code, any ideas?

JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!

Attachments

Login to view attachments
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Dec 2017 10:22
You need to call Render() so that your sprite and text are rendered to the RenderImage. Then you can use the render image on a sprite.

Your also deleting the image within the same function before using it. Unless you want to update the renderimage reguarly, you dont need to delete and rerender it. I can post a simple example if wanted.
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 30th Dec 2017 12:50
Hi,

Have below code and still get white buttons with no text?:



Any ideas?
I am on Linux, maybe it only works on Windows(R) ?
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Dec 2017 14:41
Heres an example that works fine on windows (You will need an image for the background called Test.png)



This creates text on top of the Test.png and then uses the rendered image on a sprite which moves accross the screen.

Try to get something nice and simple working first - like the above then add it to the full game
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 30th Dec 2017 18:22 Edited at: 30th Dec 2017 18:23
Hi,

I tried your code it does the Test.png(with transparency) fine,
but after two hours of fiddling I still can't get any text to display?

About to give up, but I really need this feature for optimization of game.
Any ideas... I am on Linux - perhaps it won't work on Linux?

JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!

Attachments

Login to view attachments
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Dec 2017 19:04
I've tried my code above on Windows and Android and it works fine on both. (Test.png is a green arrow)


In your version you have assigned a font (ID 999) but I dont see that you have created or loaded one?
Also, make sure you text is LARGE enough to see...make it really big as 15 high text on a 1080p virtual resolution will mean its just 4 pixels high on a 256x256 pixel render image
Also make sure it is not black text being printed onto a black background or it will not be seen.

Work on just printing nothing but text to the render image first if you have to.

If it definately wont work on linux then it can be reported as a linux specific bug

JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 30th Dec 2017 19:14
Ok, I got it now...
Many thanks!
Have a prosperous New Year!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 30th Dec 2017 21:19
Thought I had it, everything works but the transparency of the image is not preserved?
I'll put this aside for now, and continue with something else...
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Dec 2017 21:30 Edited at: 30th Dec 2017 21:32
try SetSpriteTransparency( iSpriteIndex, mode )
make sure there is nothing behind your sprite as well. what i do is;
setrendertoimage()
clearscreen()
drawsprite()
setrendertoscreen()

Login to post a reply

Server time is: 2024-11-22 20:22:27
Your offset time is: 2024-11-22 20:22:27