Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Android / LibGDX: Images disappear after i start my debug .apk from widget  (Read 18507 times)
0 Members and 1 Guest are viewing this topic.
Offline Norakomi
« Posted 2014-10-01 20:02:40 »

Hi,

I created a game, which works fine on my computer.
I created a debug .apk in Android Studiuo via the Gradle View -> Build & then copied my android-debug.apk & android-debug-unaligned.apk to the download folder of my Android Device.

Now when on my android device I clicked on one of my files the device ask if I wanna install it and choose yes and subsequently I open my game and it run fine.

Now the porblem occurs when i quite the game and try to restart the game from the widget that after the installation has been put on my android-"desktop" (main screen with all the apps you can click).


If i start it from the widget my graphics are messed up and missing & i have no idea why?
Logo image missing from splashscreen. When switching to MenuScreen the image there is missing. And when I switch to my game screen graphics get totally messed up.

When i re-install the game and run it again, there is no problem.

Anyone?

Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #1 - Posted 2014-10-01 22:11:10 »

Context loss.

If you are using static fields for assets, now is the time to stop. Have a look at AssetManager for an easy to use asset cache.

Also if you are disposing of assets, stop it. Unless you are 100% sure you won't ever need them again, never dispose of them, the garbage collector will hate you for it.

If you don't want to use AssetMananger, simply having a reload assets method that re-loads all the assets from internal storage after the app resumes is usually enough. If you have a lot of stuff to load, be prepared for a nice black loading screen for x amount of time.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline Norakomi
« Reply #2 - Posted 2014-10-02 09:22:16 »

That's probably it Gibbo.
I was already wondering why people were so against using static fields cause it worked so convenient for me (untill now ^_^) to store all assets in one class and just be able to call them when needed with a static import.

And yes, I also have been adding everything that's disposable to my dispose methods:
All the tutorials I went through i always see instructors telling things like: "make sure you dispose the spritebatch or the texture in the dispose method".

Gonna change these things today and see if it'll work

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #3 - Posted 2014-10-02 19:13:49 »

And yes, I also have been adding everything that's disposable to my dispose methods:
All the tutorials I went through i always see instructors telling things like: "make sure you dispose the spritebatch or the texture in the dispose method".

Yeah, a lot of people do that. I really don't get why, you rarely use enough of such things to grant them needing to be disposed. You usually have a Spritebatch or 2 and they are usually used in ever game state, like the menu and loading screen. Textures get loaded once, then you just transform them before drawing them.

1 Texture, many Sprites.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline Norakomi
« Reply #4 - Posted 2014-10-10 13:12:18 »

So now i changed my code and load my textures in the constructor, like:
1  
2  
3  
4  
   
   public Texture UI = new Texture("pacmanbow_ui_UP_800x480.png");
   public Texture BUTTONLEFT = new Texture("button_left_150x119.png");
   public Texture BUTTONUP = new Texture("button_up_150x119.png");


etc.

But now when i test my app on my android device the sizes of my textures get messed up (twice as big). And all graphics gets messed up.


My TiledMap that I am rendering with libGDX's tilemapRenderer get's displayed ok though.
It seems as if everything else gets scaled up by a factor 2 except for the tilemaprendering (which doesnt make sense to me)

Created a post here and on stackoverflow, but no responds yet.

Any idea how to fix this?

Pages: [1]
  ignore  |  Print  
 
 

 
DesertCoockie (20 views)
2018-05-13 18:23:11

nelsongames (68 views)
2018-04-24 18:15:36

nelsongames (65 views)
2018-04-24 18:14:32

ivj94 (748 views)
2018-03-24 14:47:39

ivj94 (79 views)
2018-03-24 14:46:31

ivj94 (595 views)
2018-03-24 14:43:53

Solater (95 views)
2018-03-17 05:04:08

nelsongames (168 views)
2018-03-05 17:56:34

Gornova (378 views)
2018-03-02 22:15:33

buddyBro (1038 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!