Search the Community
Showing results for tags 'cache'.
-
Hello friends. I need a little help in my project. I have array of images with id and url. any part of those images can be rendered in different occasions, based on user filtering. I have custom resource manager which saves all downloaded images (or failed downloads) with id and resource returned by PIXI.Loader, and for each new image checks if texture is already available, if not adds id and url to Loader and loads. Now my problem is that image array itself is also user defined, so url's might be incorrect or duplicate. If there's two images (two different IDs) to be displayed and they have same url, I technically dont have them downloaded because I'm checking with id and they have different id, so I'm adding both to the Loader resource and load. I dont know how loader handles that but it throws this warning: BaseTexture added to the cache with an id [image url] that already had an entry Warning itself is not big of a problem, but I think loader still downloads the image twice and then tries to cache it, and then is this warning thrown. so I dont want download to be performed twice when I know that i already have a texture (or will have with different resource I guess). Can anyone please help me. I dont even know what can be the correct fix in this case, let alone how to do that
-
My image keeps displaying as a green box with a cross through it, even though I'm nearly exactly the same loader event code given in the examples given here and here. My code looks something like this, but for some reason the image is always displayed as a geen box with a line through it, as though it failed to load the image correctly. Any insights as to what this might be? I promise it's not a typo! var config = { type: Phaser.AUTO, width: 1000, height: 600, scene: { preload: preload, create: create, pack: { files: [ { type: 'image', key: 'loading', url: 'assets/laptop.png' } ] } } }; var game = new Phaser.Game(config); function preload () { loading = this.add.image(500, 300, 'loading'); var progress = this.add.graphics(); this.load.on('progress', function (value) { progress.clear(); progress.fillStyle(0xffffff, 1); progress.fillRect(300, 270, 800 * value, 60); }); this.load.on('complete', function () { progress.destroy(); loading.destroy(); }); //...load other files } .
-
Hey, I got some scenes, which loading assets only needed in those, I would like to clear the cache out of the files when a new scene is started so that the memory is free again. But I can't find an example or something in the docs. I had a look at this.scene.cache.destroy(); But when I do this in a constructor: It throws an error that cache is not defined. Or at the first line in preload: it messes up the files that will be loaded afterward. Can anyone help me out regarding this? cheers
- 1 reply
-
- loader
- delete loaded files
-
(and 2 more)
Tagged with:
-
I'm using the animated tiles plugin from nkholski with the key 'animatedTiles' (how did I come up with that? It's genius). At a certain point I am destroying the game with `game.destroy(true)`. Unfortunately, when creating a new game I'm getting a warning "Scene Plugin key in use: animatedTiles" that then leads to an error "Uncaught TypeError: Cannot read property 'init' of undefined". I've checked the scene and sure enough, the plugin has not been added to it. I tried destroying the game cache before destroying the game, but that just gave me an error too. Josh
-
I'm making small turn based game tic-tac-toe using phaser 3. Is it possible to cache assets and all the files needed to run game so that game can be played offline so that no internet connection is needed and every file is loaded from cache (providing native like experience)? Does service worker would do the trick? What are the common approaches to speed up the loading process and caching in HTML5 games?
-
I am making a level viewer for a game using phaser, I loop through a large array representing the game grid and take the item names from the game save and place them in my phaser world in a loop. I take whatever the game name for the item is and map it to a phaser image, my issue is that I don't want to map every possible item type to an image, if phaser askes for an image that i have not loaded, can I just ignore it without the green texture being plastered over it?
-
Hello, Can anyone share information how can I do manual caching of sprite or speed up rendering in general? If I have group with lots of small sprites, it's wise to convert it into single BitmapData and use it as texture to prevent recalculations. However, I have no clue how can I do that and what other methods Phaser may offer. Thanks everyone in advance for help
-
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"?
-
Hey, i'm trying to get the data source from a loaded Texture in BABYLON. But I haven't found a way to do this. Basicly my idea is to get the data from the image and save it as base64 in the local cache. And then I can get the image from the cache again and load it into BABYLON. This should improve performance and result in faster loading times once you already loaded the scene once. Does this accually makes sense or is there a better way of caching textures?
-
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; this.game.load.audio(soundName, "assets/audios/music/" + soundName + ".ogg"); } this.game.load.audio("menu", "assets/audios/music/menu.ogg"); this.game.load.audio(ESounds.ACERTOU, "assets/audios/" + ESounds.ACERTOU + ".ogg"); this.game.load.audio(ESounds.ERROU, "assets/audios/" + ESounds.ERROU + ".ogg"); this.game.load.audio(ESounds.ANDANDO, "assets/audios/" + ESounds.ANDANDO + ".ogg"); this.game.load.audio(ESounds.CAINDO, "assets/audios/" + ESounds.CAINDO + ".ogg"); this.game.load.audio(ESounds.CLICK_BT, "assets/audios/" + ESounds.CLICK_BT + ".ogg"); this.game.load.audio(ESounds.CLICK_RUN, "assets/audios/" + ESounds.CLICK_RUN + ".ogg"); this.game.load.audio(ESounds.GRAB_ARTIFACT, "assets/audios/" + ESounds.GRAB_ARTIFACT + ".ogg"); this.game.load.audio(ESounds.PUT_ARTIFACT_ALTAR, "assets/audios/" + ESounds.PUT_ARTIFACT_ALTAR + ".ogg"); this.game.load.audio(ESounds.BREAK_ARTIFACT, "assets/audios/" + ESounds.BREAK_ARTIFACT + ".ogg");
-
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(){ this.game.stage.backgroundColor = '#85b5e1';this.game.add.image('platforma', 'assets/platform.jpg');this.game.add.image('jucator', 'assets/player.jpg');}, create: function(){ player = this.game.add.sprite(0,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!
-
just look into PIXI example http://pixijs.github.io/examples/#/basics/video.js 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?
- 2 replies
-
- mp4
- ref number
-
(and 1 more)
Tagged with:
-
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: https://drive.google.com/open?id=0BxggOFF8_iXkb3JRRjg0YkJtRzQ Here is a playground, on the playground it is the BOTTOM 0.5px that get cutoff.. http://babylonjs-playground.com/#20MSFF#64
- 11 replies
-
- compatibility
- cross-browser
-
(and 6 more)
Tagged with:
-
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
-
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 cachethis.game.cache.addRenderTexture('starRT', renderTexture );// check starRT is in cacheconsole.log(this.game.cache.checkRenderTextureKey('starRT')) // true// Error: Phaser.Cache.getImage: Key "[object Object]" not found in Cache.var sprite = this.game.add.sprite(0,0,this.game.cache.getRenderTexture('starRT'));sprite.x=128;this works fine though, but obviously it's not being pulled from the cache var sprite2 = this.game.add.sprite(0,0,renderTexture);
- 2 replies
-
- graphics
- BitmapData
-
(and 2 more)
Tagged with:
-
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.
- 2 replies
-
- phaser
- texturepacker
-
(and 2 more)
Tagged with:
-
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
-
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?
-
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.
-
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 JSON:this.game.load.atlasJSONHash(theID, "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 following:this.game.cache.removeTextureAtlas(theID);Any help would be greatly appreciated I have successfully removed sounds and images, but not atlas.
-
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?
-
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?
-
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?
-
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 ?
- 1 reply
-
- atlasjsonhash
- cache
-
(and 2 more)
Tagged with:
-
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.