Search the Community

Showing results for tags 'cache'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 37 results

  1. Hi, I have a folder with 23MB of sounds (including music), all of them are in .ogg format because I need to support really old browsers. When loading those sounds, memory usage goes up to 900MB. If I comment the lines below, it stays about 90MB. What am I doing wrong? Controller.numMusic = 5; //Load music: for (var i = 0; i < Controller.numMusic; i++) { let soundName:string = "music" + i;, "assets/audios/music/" + soundName + ".ogg"); }"menu", "assets/audios/music/menu.ogg");, "assets/audios/" + ESounds.ACERTOU + ".ogg");, "assets/audios/" + ESounds.ERROU + ".ogg");, "assets/audios/" + ESounds.ANDANDO + ".ogg");, "assets/audios/" + ESounds.CAINDO + ".ogg");, "assets/audios/" + ESounds.CLICK_BT + ".ogg");, "assets/audios/" + ESounds.CLICK_RUN + ".ogg");, "assets/audios/" + ESounds.GRAB_ARTIFACT + ".ogg");, "assets/audios/" + ESounds.PUT_ARTIFACT_ALTAR + ".ogg");, "assets/audios/" + ESounds.BREAK_ARTIFACT + ".ogg");
  2. just look into PIXI example and replace the path 'required/assets/testVideo.mp4' to 'required/assets/testVideo.mp4?123', then the video will disappear, and there is no error image. Is it a bug? or I can't add ref number to a mp4 file?
  3. Hi, I was wondering if someone had experienced slight differences in "offsets" using sprite2D texture and wether it might be related to caching. As an example I have a fairly small texture of 16*16 here in svg, but i tried also using png, same problem. That's the begining of the sprite texture zoomed in 4800% When using it in chrome with a code like this: const crossSheet = taskObject.cloneAssetIntoScene(R.get.crossSheet, scene) crossSheet.hasAlpha = false const cross = new BABYLON.Sprite2D(crossSheet, { parent: canvas, id: 'cross', marginAlignment: 'v: center, h: center', spriteSize: new BABYLON.Size(16, 16), spriteLocation: new BABYLON.Vector2(0, 0), }) cross.spriteFrame = R.get.cross_predict The texture is at the center of the screen here, in chrome the top misses 0.5px In Safari there is a difference in colors and width of strokes: If now I am using a 16,17 sprite size i get a correct sprite in chrome: But somehow it is seems worst in safari: Any clue ? Do you think it is related to the caching strategy ? @Nockawa Here is the link to the texture: Here is a playground, on the playground it is the BOTTOM 0.5px that get cutoff..
  4. Hi guys, I load about 10mb of data for my game. But each time I refresh the page, everything has to be re-downloaded. It's like phaser can't save anything in the browser cache? Is there any way to fix this? Thanks, pyre
  5. Hi, I'm trying to work out how to create a shape with graphics, cache it and add it to a sprite to use repeatedly I was trying to recreate the intro background on this video (see below, not the video thumbnail but the first thing you see when you actually play it). I realised drawing all the star graphics and fills directly over time would probably be too slow, so it would be better to cache the star & it's trail as a bitmap and then create multiple sprites from that. I want to create the graphic early on and pull it out of the cache later. I'm getting an error though. The key is there but it can't find the texture. Does it need longer to store before trying to pull it out again? Obviously I could use a PNG but i'd prefer to be able to generate the graphics at runtime thanks for any advice. J // draw graphics to renderTexturevar renderTexture = this.add.renderTexture(graphics.width, graphics.height);renderTexture.renderXY(graphics, 0, 0, true);// add renderTexture to'starRT', renderTexture );// check starRT is in cacheconsole.log('starRT')) // true// Error: Phaser.Cache.getImage: Key "[object Object]" not found in Cache.var sprite =,0,'starRT'));sprite.x=128;this works fine though, but obviously it's not being pulled from the cache var sprite2 =,0,renderTexture);
  6. Hello! I finally decided to try to use TexturePacker. This tool looks promising. Now I am just rewriting tons of my code. Here's the question, I hope some of you, friends, might be able to help me: My old code: var background = game.cache.getImage(backgroundName); something.drawImage(background, 0, 0, background.width, background.height, 0, 0, gameWidth, gameHeight); Can I do the same thing, but with background image being placed into texture atlas which will also include multiple other images? How can I do ' var background = game.cache.getImage(backgroundName);', but with texture atlas use? It seems methods like getFrameData return only some info strings.
  7. Hello, I anyone else experiencing serious cache isues using the latest version of chrome? I work on my server and update fles quickly, and a month ago I coud refresh and any new changes would be updated as the chrome browser would reload the updated file. Then about a month ago (maybe two), I had to open a new tab to get chrome to load a same name script whic was updated. But as of last week, I now must clear my cache regardless to get chrome to release any previous same name assets or scripts. If anyone has a solution to this, I'd love to hear; or if you are also experiencing the same issue. Thanks DB
  8. Hi, guys. I know that for an image I can retrieve it's width issuing the command game.cache.getImage(key).width; But suppose that instead of a single image you have an atlas named 'atlas' and its key is 'atlas' and that it contains an image named 'logo.png'. How could I get the width of image named 'logo.png' from cache object?
  9. Hello, i recognized on my own project where i want to add this filter that in firefox and safari this filter does not work the first time when you visit the page.. after it cached the .frag file mean on reload it works.. i also tried to cache the file first with jQuery.get but with no success. any help? Firefox: 46.0.1 Macbook Pro. EDIT: Really nobody? I mean this also happens on the example-page of Phaser, not only on my project.
  10. Remove cache from atlasJSONHash

    I have a game on mobile which gets slower and slower as you progress which I have identified down to the cache not being emptied. I have successfully loaded in a number of pngs and json files by using the following in a loop through, "image.png", "data.json");Then I am successful in removing the sprite from the scene using the following:item.destroy();However when I try to then remove the png and json atlas json files from the cache, it errors, any ideas? I am using the;Any help would be greatly appreciated I have successfully removed sounds and images, but not atlas.
  11. Preloader breaks loading video

    I have a custom Preloader which has been working fine, but now when i try to preload a 8.43 MB mp4 WebOptimized video (made with HandBrake) my preloader breaks with the message: Phaser.Loader - active loading canceled / reset If I remove the video the preloader loads fine OR if I clear the cache file of the video (on the browser) it also loads fine! When the loading breaks I get the 304 Not Modified status code for the video. What could be causing this?
  12. Key " " not found in Cache.

    Hi guys, I just started out with Phaser and I was thinking about creating a basic game with a guy jumping around from scratch. I searched this website for an answer but I couldn't actually find one that fits or I was too stupid to understand it. So why when I want to create an image on the canvas it says "Phaser.Cache.getImage: Key "jucator" not found in Cache." ? Here's my code: <html><head><meta charset="UTF-8" /><title>Dani Mocanu runs</title><script type="text/javascript" src="JS/phaser.min.js"></script></head><body><script type="text/javascript"> var player; new Phaser.Game(800, 600, Phaser.AUTO, '', {preload: function(){ = '#85b5e1';'platforma', 'assets/platform.jpg');'jucator', 'assets/player.jpg');}, create: function(){ player =,0,'jucator');}, update: function(){ }})</script></body></html>I'm using WAMP in order to 'host' the game. Thanks for the info and if you have any advice about how should I be learning Phaser in a better way or any advice about anything for a beginner please let me know. Thank you!
  13. I want to make several unit tests that test my loading functionality. That means i have to run Phaser.Cache.destroy() just so I make sure the assets were not loaded by the previous test. The problem is destroy() makes the cache null which is not what I want. I just want to clear the data it holds. I even tried this: game.cache = new Phaser.Cache(game); But it doesn't seem to be working. What should I do in this case?
  14. Unit Testing my Game with JSUnit

    I have this test: function testLoadAtlasJSONHash_CreateCustomJSONAtlasAndRunTheFunc_PassesIfThePhaserLoaderContainsTheAssetKey () { var keyName = 'KEY_NAME', keyValue = 'keyValue', sheetUrl = 'assets/testing/images/guidesAndBackgrounds.png', sheetConfigUrl = 'assets/testing/settings/guidesAndBackgroundsHash.json'; WML.addConstant(WML.ImageAssetKeys, keyName, keyValue); game.load.atlasJSONHash(WML.ImageAssetKeys[keyName], sheetUrl, sheetConfigUrl); assertTrue(game.load.checkKeyExists(Phaser.Loader.TEXTURE_ATLAS_JSON_HASH, keyName)); } Note: I have separate tests which pass for WML.ImageAssetKeys[keyName] and for WML.addConstant() And I am not sure where it is failing. checkKeyExists() returns false. How can I know or find why it returns false?
  15. I am adding new Atlas Json Hash object and I want to check if its key exists in the Loader. I would do this: game.load.checkKeyExists(type, myKey) Bu I am not sure what to use as type. I know I should use game.cache.someconstant but which on is for Atlas JSON Hash ?
  16. In my application I have animation packages(babylon files) that are very large and take a while to download from the server. This download time is helped by using the enableSceneOffline and enableTexturesOffline in the manifest file, but we still have to deal with the initial load each time. Is there a way to load those so they are available in the background without having to render them on screen until we are ready for the user to interact with them? The load times are excessive for each package, but it would help if I could load a new babylon file to have it ready for when the user is done interacting with the first.
  17. Texture caching

    Hey guys! I'd like to cache my textures into IndexedDB, I saw that Babylon.js is capable of it, but my case is that, I don't have a "scene mesh babylon" file, I just create a simple Babylon.Scene and add some custom meshes, with textures. And I'd like to cache those textures, is there a workaround to "make babylon.js believe it is a scene loaded from a file and force checking manifest and force using indexed db for textures"?
  18. Hello. I am trying to use a tilemap (which is not persisted to any form of database or file) over several states by using the cache. STATE ONE // Creating the tilemap..var map =;map.addTilesetImage('ground_1x1'); map.create('level1', 40, 40, 32, 32);map.setLayer(0);// In this state I am editing the map by adding / removing tiles from the layers// I then add it to the'test', map);// Then when changin state, I'm clearing world but keeping cache:this.state.start('LevelTwo', true, false);STATE TWO// I am loading the map from the'test','test').url, null, Phaser.Tilemap.CSV); // And adding it back to the'test');But this doean't work.. I have tried to use my cached map as both the url and/or data argument when loading it back to the game, but nothing seems to work. It is possible that this is conceptually wrong, and that there is some much easier way to do this then to use the cache like I am trying to - if so please tell me! I do not, however, want to keep world between states since most of the world related information is not shared between states. I am also wondering how to get the actual map data from a map, since i would like to persist it at a later point.. as i inspect my map, I notice that the data field is empty, is there something that needs to be done to generate this? Thanks in advance! / AS
  19. Hi, I'm trying to check if the audio is ready before start the MainMenu. create: function () { this.addGameSrc(); Vendor.addSound(); Vendor.addMusic('main_menu', true); audios = [ music, sfx_Click, sfx_Drop, sfx_Explode ]; console.log(audios); this.status.setText('DECODING AUDIOS...'); this.sound.setDecodedCallback(audios, this.start(), this); }, start: function () { this.status.setText('READY'); setTimeout(function () { game.state.start("MainMenu"); }, 250); console.log("Splash\t\tOK"); },ERROR: TypeError: this._watchCallback is undefined I also tried this code: create: function () { this.addGameSrc(); }, update: function () { if (game.cache.isSoundReady('click', 'main_menu')) { this.startMenu(); } else { this.status.setText('DECODING AUDIOS...'); }; }, startMenu: function () { this.status.setText('READY'); this.state.start("MainMenu"); console.log("Splash\t\tOK"); },But it takes so long for decode, tested with S6 Edge and about 10 seconds waiting, doesn't matter if the audio is an mp3 or ogg with 5k or 500k, if it's one single file or ten files, make no sense for me... Plz, Someone can help me to fix this?
  20. Remove cache from atlasJSONHash

    I have successfully loaded in a number of pngs and json files by using the following in a loop through JSON:[i].animID, "assets/images/npcs/"+gameData.npc[i].animImagePath+"", "js/npcs/"+gameData.npc[i].animDataPath+"");Then I am successful in removing the sprite from the scene using the following: item.destroy();However when I try to then remove the png and json atlas json files from the cache, it errors, any ideas? I am using the following:[i].animID);
  21. Hello! I've been using phaser and to create a multiplayer game for about 5 days now. However, a weird error is happening: 'players' is a key for a image that I'm using to show other players (it's not the same of your player). Because I'm a newbie with phaser, maybe I'm missing something very basic, but until now I don't have idea of what it is. Here is the start of my code: var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, 'kabar', {preload: preload, create: create, update: update});function preload(){ var loadingLabel = game.add.text(window.innerWidth / 2 - 85, window.innerHeight / 2 - 10, 'Loading...', {font: '30px Courier', fill: '#fff'}); game.load.image('player', 'assets/player/player.png'); game.load.image('players', 'assets/player/players.png'); game.load.image('bullet', 'assets/bullet1.png'); game.load.image('space', 'assets/space.gif'); game.load.start(); // I tried without this line too, didn't work }And here are both sockets where I load these images and the error happens: var socket = io(); socket.on('newPlayer', function (data){ var uID = data.uID; players[uID] = new EnemyPlayer(data.oPlayers[uID].id, data.oPlayers[uID].x, data.oPlayers[uID].y, data.oPlayers[uID].angle); players[uID].id = data.oPlayers[uID].id; players[uID] = game.add.sprite(0, 0, 'players'); players[uID].anchor.setTo(0.5, 0.5); game.physics.enable(players[uID], Phaser.Physics.ARCADE); players[uID].body.drag.set(0.2); players[uID].body.maxVelocity.setTo(400, 400); players[uID].body.collideWorldBounds = true; }); socket.on('update', function (data){ playerQuantity = data.playerQuantity if (userID == playerQuantity && userID > 1){ players = data.oPlayers; for (var i = 1; i < playerQuantity; i++){ if (i != userID){ players[i] = new EnemyPlayer(players[i].id, players[i].x, players[i].y, players[i].angle); players[i].id = players[i].id; players[i] = game.add.sprite(players[i].x, players[i].y, 'players'); players[i].anchor.setTo(0.5, 0.5); game.physics.enable(players[i], Phaser.Physics.ARCADE); players[i].body.drag.set(0.2); players[i].body.maxVelocity.setTo(400, 400); players[i].body.collideWorldBounds = true; players[i].position.x = players[i].x; players[i].position.y = players[i].y; players[i].angle = players[i].angle; } } } });(The socket 'New Player' is called for an existing player when a new player joins, while the socket 'Update' is called for the new player to draw all the other players) Could it be an error involving Or is it something that I'm missing?
  22. Problem with text in cache

    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?
  23. Phaser.Cache Errors in 2.4.4

    Hi! I just updated from Phaser 2.2.2 to 2.4.4 and i'm now experiencing sporadic errors from the cache during GameState create, like this: Phaser.Cache.getImage: Key "" not found in Cache. I see this on both Chrome and Firefox, but Internet Explorer 11 seems fine. I believe this is a timing issue, since if I stop execution with a breakpoint in the start of the GameState create method I do not see the issue. Also refreshing a couple of times usually makes the problem go away, and all assets are available in the cache again. Cheers, Klaus
  24. somebody asked if you could tint a whole sprite atlas. My idea was to load the same PNG separately as an image, tint it, draw it to bitmap data and then overwrite the cache object for the atlas. I can create a dataURL for the image but I'm not sure it's possible to overwrite an existing cache item's URL etc. (obviously this is likely to be calling private methods or rather updating non-public properties, but it'd still be interesting to know if it's doable) thanks for any advice J.
  25. This isn't to ask for help, but more of a suggestion for a fix in future Phaser versions, and maybe also a help to other Phaser Developers. In my game I save a screenshot of the canvas and save it to the users local JSON sessionstorage to call upon later. Now with that Image data URI saved I wanted to paste the image onto the screen, bearing in mind you need to cache the image first: create: function () { /* Caching START */ this.gameScreenshot01 = gameData.playerSettings[0].savedGames[0].screenshot; this.gameScreenshot01Image = new Image(); this.gameScreenshot01Image.src = this.gameScreenshot01;'image01', null, this.gameScreenshot01Image); /* Caching END */ /* Now actually paste the image to the canvas START */ this.gameScreenShotInput =, 100, 'image01'); /* Now actually paste the image to the canvas END */ }, Now this works great for desktop, but not mobile. A fix for it I have found is that mobiles seem to have a problem caching it the first time. The fix? Cache it twice! BUT you have to do it among 2 different functions throughout the project and then paste the image to the canvas. Hope that's helps anyone out there. My mobile is on IOS9, so maybe there were a few bugs out there at the beginning of this release. Thanks