SOLVED:
Thanks walterf25!!
_______________________________________________________________
Hello GDX gurus!
My game has a small shop where you can buy an "Extra Life".
The default texture for this item is bundled with the apk and initialized in LG_Create.
If I want, however, to update the in-game shop graphical assets, I don't want to force the user to download and updated version of the game.
Instead, the game itself checks the server for new textures and downloads them accordingly.
So far this part is done and working properly.
The code below saves the new texture in the external assets folder:
Now... how can I load this new PNG file into the 'extra_life_source' variable (lgTexture)?
I can't do it in LG_Create since the download happens during LG_Render.
Please help me with this IF statement in LG_Render, since the above it's only pseudo-code.
Thanks in advance.
B4X:
extra_life_source.dispose
extra_life_source.InitializeWithFile(lGdx.Files.Absolute(File.DirDefaultExternal & "/item01buy_texture.png"))
extra_life_downloaded_buy_texture = False
File.Delete(File.DirDefaultExternal, "item01buy_texture.png")
_______________________________________________________________
Hello GDX gurus!
My game has a small shop where you can buy an "Extra Life".
The default texture for this item is bundled with the apk and initialized in LG_Create.
If I want, however, to update the in-game shop graphical assets, I don't want to force the user to download and updated version of the game.
Instead, the game itself checks the server for new textures and downloads them accordingly.
So far this part is done and working properly.
The code below saves the new texture in the external assets folder:
B4X:
Sub JobDone (Job As HttpJob)
...
Case "GetItem01BUY_Texture"
If extra_life_downloaded_buy_texture = False Then
If File.Exists(File.DirDefaultExternal, "item01buy_texture.png") Then File.Delete(File.DirDefaultExternal, "item01buy_texture.png")
Dim input As Bitmap
Dim output As OutputStream
input = Job.GetBitmap
output = File.OpenOutput(File.DirDefaultExternal, "item01buy_texture.png", False)
input.WriteToStream(output, 100, "PNG")
output.Close
If File.Exists(File.DirDefaultExternal, "item01buy_texture.png") Then
extra_life_downloaded_buy_texture = True
End If
End If
...
End Sub
Now... how can I load this new PNG file into the 'extra_life_source' variable (lgTexture)?
I can't do it in LG_Create since the download happens during LG_Render.
B4X:
Sub Globals
...
Dim extra_life_source As lgTexture
...
End Sub
Sub LG_Create
...
extra_life_source.Initialize("default_texture.png")
...
End Sub
Sub LG_Render
...
If Downloaded_Texture = True Then
'Replace the default texture with new downloaded texture
extra_life_source = "item01buy_texture.png"
'and do this only one time
Downloaded_Texture = False
End If
...
End Sub
Sub LG_Dispose
...
extra_life_source.dispose
...
End Sub
Please help me with this IF statement in LG_Render, since the above it's only pseudo-code.
Thanks in advance.
Last edited: