Jump to content

Problem with text in cache


bartk
 Share

Recommended Posts

Hey,

 

I've got a weird problem with loading a text into a variable from the cache.

 

Slight background, I started with a txt file called test1.txt which contained the text "This is a test". (Just to try out the functionality)

Later I changed the text to a part of lorem ipsum to experiment with longer texts and to improvise pagination in a dialogue bubble. However, the variable kept returning "This is a test".

 

My code:

game.load.text('test1', 'txt/test1.txt');...text = game.cache.getText('test1');speech = game.add.text(0, 0, text, { boundsAlignH: "left", fontSize: '12px', fill: 'black', wordWrap: true, wordWrapWidth: 160 });

I keep failing to make it recognise that the txt file's contents have changed, anyone know what I'm doing wrong?

Link to comment
Share on other sites

I'm not sure, but I think removing it from the game's cache may not necessarily mean it gets removed from your browser's cache.

if you're deploying this for people to play, one way is to use versioning (e.g., http://www.html5gamedevs.com/topic/7754-preloaded-image-doesnt-change/) 

Otherwise, if it's just for debugging, you can either disable caching in your browser, or clear it each time.

Link to comment
Share on other sites

If you're using Chrome, you can open the devtools and find an option "Disable Cache (while devtools are open)": https://developer.chrome.com/devtools/docs/settings

 

From then on you can keep your devtools open (maybe as a separate window in the back, even) to keep the cache disabled while you're working on your game.

Link to comment
Share on other sites

If you're using Chrome, you can open the devtools and find an option "Disable Cache (while devtools are open)": https://developer.chrome.com/devtools/docs/settings

 

From then on you can keep your devtools open (maybe as a separate window in the back, even) to keep the cache disabled while you're working on your game.

 

Yes, I'd suggest using this approach while developing because if not, your browser cache will fill up considerably quickly given the number of times you'll expect to be launching the game while debugging.

Safari also has the option to disable cache, too (and I suspect Firefox would probably have it too)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...