Android Tutorial Introduction to the libGDX library

shashkiranr

Active Member
Licensed User
Hi Fred,

In a live wallpaper application, I am loading a bitmap font using the asset manager but the font is not getting recognized when i check in the log. the font is in the assets folder.

B4X:
assetmanager.Initialize("AM")
    assetmanager.Load("font/lqbm.fnt",assetmanager.TYPE_BitmapFont)
    Log("------")
    Log("Loaded assets:")
    Dim L As List = assetmanager.LoadedAssetNames
    L.Sort(True)
    For i = 0 To L.Size - 1
        Log("- " & L.Get(i) & " (" & assetmanager.GetAssetType(L.Get(i)) & ")")
    Next
    Log("------")
Kindly let me know the mistake i am making here

Regards,
SK
 

Informatix

Expert
Licensed User
Hi Fred,

In a live wallpaper application, I am loading a bitmap font using the asset manager but the font is not getting recognized when i check in the log. the font is in the assets folder.

B4X:
assetmanager.Initialize("AM")
    assetmanager.Load("font/lqbm.fnt",assetmanager.TYPE_BitmapFont)
    Log("------")
    Log("Loaded assets:")
    Dim L As List = assetmanager.LoadedAssetNames
    L.Sort(True)
    For i = 0 To L.Size - 1
        Log("- " & L.Get(i) & " (" & assetmanager.GetAssetType(L.Get(i)) & ")")
    Next
    Log("------")
Bitmap fonts are made of two files: an image (png format) and a text file (your .fnt file). The image is referenced in the text file by the line:
page id=0 file="font.png"
You should check that the image is not missing and that the path and name of the image in the text file lead to the right file.
 

shashkiranr

Active Member
Licensed User
Hi Fred,

I created the bitmap font using libgdx nightly build as you mentioned and copied both the font file and image to the assets folder as given in the asset manger tutorial but it is not loading the font.

Edit : I am calling this in LG_Create in the live wallpaper template
 
Last edited:

Informatix

Expert
Licensed User
Hi Fred,

I created the bitmap font using libgdx nightly build as you mentioned and copied both the font file and image to the assets folder as given in the asset manger tutorial but it is not loading the font.

Edit : I am calling this in LG_Create in the live wallpaper template
Did you check the path to the image in the text file?
 

shashkiranr

Active Member
Licensed User
Hi Fred,

I checked the path as you mentioned in the bitmap font. its given as
B4X:
page id=0 file="lqbm.png"
. I have one question though i am calling this in the wallpaper service. Does it hold good because i know it works in Activity Module.

Edit : the asset manager is picking my font in activity module but not in the wallpaper service module.


Edit 2 : I got it working :) removed the assetsmanager and used the lw.files.internal to access the assets folder.

Regards,
SK
 
Last edited:

shashkiranr

Active Member
Licensed User
Hi Fred,

In my wallpaper application, I have initially loaded the texture with an image "1.png". When the user selects a different image, im using
B4X:
Texture.InitializeWithFile(LW.Files.internal("SelectedImage"))
to load the texture with this new image but im getting a force close.
I even tried to dispose the texture and initialize it again with the new image and got the same result.

How do you clear the old image and assign the texture with the new one.

Kindly let me know your inputs.

Regards,
SK
 

Informatix

Expert
Licensed User
Hi Fred,

I checked the path as you mentioned in the bitmap font. its given as
B4X:
page id=0 file="lqbm.png"
. I have one question though i am calling this in the wallpaper service. Does it hold good because i know it works in Activity Module.

Edit : the asset manager is picking my font in activity module but not in the wallpaper service module.


Edit 2 : I got it working :) removed the assetsmanager and used the lw.files.internal to access the assets folder.

Regards,
SK
I never tried the Asset Manager in a Wallpaper service so thanks for the report.
It's not really an issue as the Asset Manager is slow and should only be used when you need to load a lot of resources in the background; it is not suited for a live wallpaper app where no loading time should occur.
 

Informatix

Expert
Licensed User
Hi Fred,

In my wallpaper application, I have initially loaded the texture with an image "1.png". When the user selects a different image, im using
B4X:
Texture.InitializeWithFile(LW.Files.internal("SelectedImage"))
to load the texture with this new image but im getting a force close.
I even tried to dispose the texture and initialize it again with the new image and got the same result.

How do you clear the old image and assign the texture with the new one.

Kindly let me know your inputs.

Regards,
SK
Do you have this problem only in the LiveWallpaper service?
 

shashkiranr

Active Member
Licensed User
Yes . I am currently working on the live wallpaper. I have not tried texture in activity module. Is there a workaround for it?
 

Informatix

Expert
Licensed User
Yes . I am currently working on the live wallpaper. I have not tried texture in activity module. Is there a workaround for it?
In my LiveWallpaper_Smileys example, I replaced the code that stops/restarts the effect by:
B4X:
If LW.Input.JustTouched Then
      texSmiley.dispose
      texSmiley.Initialize("droid.png")
End If
... and that works fine. You have to find the problem in your code because it's not related to libGDX.
 

Informatix

Expert
Licensed User
Hi Fred,

In my wallpaper application, I have initially loaded the texture with an image "1.png". When the user selects a different image, im using
B4X:
Texture.InitializeWithFile(LW.Files.internal("SelectedImage"))
to load the texture with this new image but im getting a force close.
I even tried to dispose the texture and initialize it again with the new image and got the same result.

How do you clear the old image and assign the texture with the new one.

Kindly let me know your inputs.

Regards,
SK
I tried to load a bitmap font with the asset manager in a live wallpaper service and had no problem (with both methods: finishloading and update). Maybe your font file is corrupted or has a specific problem (could you send it to me?).
 

shashkiranr

Active Member
Licensed User
Hi Fred,

i also used the font in the assets example but it dint work, I have attached the font which i have created using Hiero for your reference.
 

Attachments

Carcas

Member
Licensed User
HI,
Forgive the simple question.
I'm used to the colors B4A ... (colors.argb (255,123,23,79))
How can I convert to libgdx (. Color.argb (?,?,?,?)) ?

There is not much documentation on the web :(
 

Informatix

Expert
Licensed User
HI,
Forgive the simple question.
I'm used to the colors B4A ... (colors.argb (255,123,23,79))
How can I convert to libgdx (. Color.argb (?,?,?,?)) ?

There is not much documentation on the web :(
From the tutorial:
"each color value ranges from 0 to 1"

From the help text of the setColorRGBA function (used many times in the examples):
"R Red, from 0 to 1
G Green, from 0 to 1
B Blue, from 0 to 1
A Alpha, from 0 to 1"

And here's the first link returned by Google for "color libGDX": http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html

Not documented indeed....
 

Carcas

Member
Licensed User
I've already read this but maybe I have not explained well

For example, I have this color ARGB (255,84,84,84) --GRAY

I would like the exact same color with float numbers.
I saw toFloatBits but I do not understand how to use it

I dont Know Java
 

Informatix

Expert
Licensed User
I've already read this but maybe I have not explained well

For example, I have this color ARGB (255,84,84,84) --GRAY

I would like the exact same color with float numbers.
I saw toFloatBits but I do not understand how to use it

I dont Know Java
You don't need to know Java, just very basic maths. If the max value for a color is 1 for libGDX, then you have simply to divide your color ranging from 0 to 255 by 255. So 0 -> 0, 128 -> 0.5, 255 -> 1, etc.
 
Last edited:
Top