abhi66 / rokon

Automatically exported from code.google.com/p/rokon
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Can't set texture to TextSprite because in method setTexture allow set only instance of FontTexture #85

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I write this code.
face = Typeface.defaultFromStyle(Typeface.NORMAL);
Font font = new Font(face);
fontTexture = font.createTexture("Test Text");
text = new TextSprite(20, 100, 12, 20);
text.setTexture(fontTexture);

What is the expected output?
A text

What do you see instead?
Return error

What version of Rokon are you using?
2.0.2

On which version of Android are you experiencing this?
2.2

Please provide any additional information below.
In method setTexture is if clause, in which an error message is nonsense:
if(!(texture instanceof FontTexture)) {
    Debug.error("Tried setting TextSprite to non-TextTexture");
    return;
}

Original issue reported on code.google.com by lehovecj...@gmail.com on 30 Jun 2010 at 4:00

GoogleCodeExporter commented 9 years ago
So I looked to the code and the problem is that the TextSprite class can write 
text  just only created by the FontTexture class. TextTexture class keep Bitmap 
object in itself (created by Font class) but the FontTexture class load Bitmap 
object from a file. I can't put Bitmap object from TextTexture to FontTexture.

Original comment by lehovecj...@gmail.com on 1 Jul 2010 at 11:03

GoogleCodeExporter commented 9 years ago
Your right ...

if(!(texture instanceof FontTexture)) {

Should be

if(!(texture instanceof TextTexture)) {

Will be fixed for next release, or see trunk.

It's also worth noting FontTexture / TextTexture apply to different situations, 
this will be explained in an example at some point. One is for a bitmap font, 
which renders character-at-a-time to a texture. One is for TTF fonts, which are 
rendered by Canvas onto a texture.

Thanks

Original comment by rtaylor205@gmail.com on 2 Jul 2010 at 1:01