Search the Community

Showing results for tags 'preload'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Found 35 results

  1. If I have multiple states (say, 30) that are somewhat resource heavy (audio, background graphic, graphics), is it better to run a single preloader at the start and preload everything I'm going to need in the game, or preload the next state ahead in each state? So if I'm in a room, and can travel to 3 other rooms from my current room, should I be preloading those 3 rooms in my current state while the player is there, etc. or preloading them all in advance?
  2. Ignore missing images

    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?
  3. load assets after preload

    Hi all, currently I got 2 state stateA assetsA stateB assetsB I want to load assetsB after stateA create completed, so when I go to stateB the preload flow can be faster even to 0. so I wrote like this in the end of stateA create part but I got some wranings this.game.load.audio('stateB1', 'assets/audio/stateB1.ogg'); this.game.load.start(); Phaser.Loader - active loading canceled / reset ----phaser-2.6.2.js:74076 and the assets are not loaded at all. so do you guys now how should I do to 【preload】assets for next state, thx
  4. Loading atlas

    Happy new year everyone!!!!!! I'm starting this new Phaser year with a big question. Is there a way to do at least one of those three things: Have multiple keys for just one atlasJSONarray.json { "frames1": [ { "filename": "frame_x", "frame": {"x":0,"y":0,"w":246,"h":642}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":246,"h":642}, "sourceSize": {"w":246,"h":642} }, ... ], "frames2": [ { "filename": "frame_y", "frame": {"x":0,"y":0,"w":642,"h":246}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":642,"h":246}, "sourceSize": {"w":642,"h":246} }, ... ], "meta": { "app": "http://www.codeandweb.com/texturepacker", "version": "1.0", "image": "frames.png", "format": "RGBA8888", "size": {"w":1904,"h":1926}, "scale": "1", "smartupdate": "$TexturePacker:SmartUpdate:7501c1db9128f0a301bfd7fdbb041683:f12b9111dd99102df2878485c54440cc:8dfa5172c304a3afa731250a934e2d8d$" } } //Load things in "frames1" with key 'spriteframe1' game.load.atlasJSONArray('spriteframe1' , 'images/frames.png' , 'images/frames.json'); //Load things in "frames2" with key 'spriteframe2' game.load.atlasJSONArray('spriteframe2' , 'images/frames.png' , 'images/frames.json'); Loading multiple atlases in just one atlasJSONarray.json { "frames": [ { "filename": "frame_x", "frame": {"x":0,"y":0,"w":246,"h":642}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":246,"h":642}, "sourceSize": {"w":246,"h":642} }, { "filename": "frame_y", "frame": {"x":0,"y":0,"w":642,"h":246}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":642,"h":246}, "sourceSize": {"w":642,"h":246} }, ... ], "meta": { "app": "http://www.codeandweb.com/texturepacker", "version": "1.0", "images": ["frames1.png", "frames2.png"], "format": "RGBA8888", "size": {"w":1904,"h":1926}, "scale": "1", "smartupdate": "$TexturePacker:SmartUpdate:7501c1db9128f0a301bfd7fdbb041683:f12b9111dd99102df2878485c54440cc:8dfa5172c304a3afa731250a934e2d8d$" } } Have the same key for two different atlases who have data for the same sprite/sequence/animation/any //Load all the frames in both files for my animation game.load.atlasJSONArray('spriteframes' , 'images/frames1.png' , 'images/frames1.json'); game.load.atlasJSONArray('spriteframes' , 'images/frames2.png' , 'images/frames2.json'); Is it possibile at least one of this three things? If yes, how? Thanks for the answers guys!
  5. Multiple upload recursively

    Good morning! I've a (really probably) noob question. I have to preload all the file in one folder and its subfolder. If I know before the upload all the stuff stored in these folders I can easly do it with game.load.images([keys], [urls?]); or game.load.pack(key, url?, data?, callbackContext?); but if I don't want to edit multiple times the string or json file (in example to have the same code valid for multiple projects or if I have some stuff now and in the future a lot more), there is a way to do it? I've google for a while finding nothing for Phaser, nor Typescript nor JavaScript. Thanks to whoever can help me! :-)
  6. Is it possible to show the loading progress of a png sptire atlas and its json file? Something like we used to do in flash with totalBytes and loadedBytes?
  7. Load text before load game

    I have a code like this: fonts.css @font-face{ font-family: 'LiberationMono'; src: url('../fonts/LiberationMono-Regular-webfont.eot'); src: url('../fonts/LiberationMono-Regular-webfont.eot?iefix') format('eot'), url('../fonts/LiberationMono-Regular-webfont.woff') format('woff'), url('../fonts/LiberationMono-Regular-webfont.ttf') format('truetype'), url('../fonts/LiberationMono-Regular-webfont.svg#webfont') format('svg'); } @font-face { font-family: 'archivoblackregular'; src: url('../fonts/archivoblack-regular-webfont.woff2') format('woff2'), url('../fonts/archivoblack-regular-webfont.woff') format('woff'), url('../fonts/ArchivoBlack-Regular.ttf') format('truetype'); } fonts = "30pt LiberationMono"; fontTitles = "50pt archivoblackregular"; ... text = this.game.add.text(this.game.world.centerX, 130, "¿What option is the correct?", { font: fontTitles, fill: "#005ba6", align: "center" }); text.anchor.set(0.5) But in the first round does not work. I have thought to use this as it says in https://hacks.mozilla.org/2016/06/webfont-preloading-for-html5-games/ var fontLoaded = false; var gameCreated = false; function createText() { if (!fontLoaded || !gameCreated) return; game.add.text(0, 0, 'Lorem ipsum', { font: '12px Amatica SC', fill: '#fff' }); } function preload() { let font = new FontFaceObserver('Amatica SC'); font.load().then(function () { fontLoaded = true; createText(); }); } function create() { gameCreated = true; createText(); } But it's a lot of code change, since my games are all with text. Thanks in advance.
  8. Why need preload STATE?

    In many examples and tutorials, there is usually one "must have" state: Preload state. There also discussion on preload state: Do we need load all assets files in preload state? BTW, I found if I load a sprite sheet from an image file in preload state, and add to game in my main state, sometimes it fails to slice my sprite sheet into each frames. Recently I load an image sprite sheet file for buttons in preload state, and add to my title state, I got the whole image show on the screen, regardless what I set frame width and height in load function in preload state. Then I put this load into the preload function of title state, it worked well. So. this made me more confused. Is this a bug? Or there are some rules for file loading? If we can't load many assets in preload state, why we need it?
  9. Is there a way to know if all the materials that have been created in a scene are done rendering without continually querying all the materials to find out if they are ready(material.isReady)? I am using several PBR materials and I have a screen that covers the scene until all the meshes are loaded, but I want to keep the scene from popping in materials after the screen is gone. Here is what I am working on for an example http://protest.jht.com/gea_engines101_new/ Thanks in advance
  10. How can i control the initilization of the game, i know that the first that phaser do is the preload function but i want to execute some Js code and till that part is finished start the game. Help please
  11. I am making a game with skins in it. When ever player changes a skin Images gets loaded again. I use this code. preload: function () { this.load.image('arm', 'asset/Theme'+this.theme+'/arm.png'); this.load.image('leg', 'asset/Theme'+this.theme+'/leg.png'); this.load.image('head', 'asset/Theme'+this.theme+'/head.png'); this.load.image('torso', 'asset/Theme'+this.theme+'/torso.png'); } gameFunction:function() { if(this.themeChanged) { this.theme = this.newTheme; game.lockRender = true; game.load.onLoadComplete.add(this.preloadComplete, this); this.preload(); game.load.start(); } } preloadComplete:function() { game.load.onLoadComplete.remove(this.preloadComplete, this); game.lockRender = false; this.addImages(); }, This gives me an error What am I doing wrong here?
  12. Hello, probably I have a very simple (and stupid?) question. When I load some sprite atlases in my preload function are they downloaded from the server when the preload is executed (and then loaded to memory), or during preload loop they are only loaded to device memory because they were downloaded earlier (before game.load function)? I need to optimise my game to download assets on many loading screens, not all at once. I did some googling but didn't find anything about downloading assets Any advice, links appreciated - thanks
  13. I get a error when I use game.state.start() function in phaser.min.js 2.4.6. I want back to previous state(in my code ,it is "Main" state) with a button tap function in "Play" state.so I use the code:game.state.start("Main").but there throw a error:Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D'. It seems like that the preload function in "Main" state been called again,because the game run well when I replace the code to : game.state.start("Main",true,true).In fact ,I must keep the game.Cache in game ,so the gamer woudn't wait for a long time. Who can help me?Thanks to any replies!
  14. 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?
  15. Hi! Does anyone know how I might be able to load a different background each time a game is started? I have three different preloaded backgrounds and would like the game to select a random one each time the game begins. I'm a complete newbie to Phaser and any help/tutorials would be hugely appreciated! Can link code if needed. Thanks!
  16. Load assets after preload

    Hi all, I wonder whether it would be possible to load an asset dynamically at a given time in Phaser rather than loading everything in the preload function. The reason for this is simple: I have a game with three different levels, all of which have different background songs; and so I'd rather only load a single song at startup to reduce loading times. Right now, my preload function looks like this: preload: function(){ game.load.audio('pixel_world', ['assets/music/pixel_world_lo.ogg', 'assets/music/pixel_world_lo.mp3']); game.load.audio('second_source', ['assets/music/second_source_lo.ogg', 'assets/music/second_source_lo.mp3']); game.load.audio('reboot_complete', ['assets/music/reboot_complete_lo.ogg', 'assets/music/reboot_complete_lo.mp3']); game.load.image('pickup', 'assets/img/pickup.png');}I tried moving one of the game.load.audio() calls to the create function instead: create: function(){ game.load.audio('pixel_world', ['assets/music/pixel_world_lo.ogg', 'assets/music/pixel_world_lo.mp3']); // good things follow...}However, the following calls fail: this.cache.isSoundDecoded(level.song)// Phaser.Cache.isSoundDecoded: Key "pixel_world" not found in Cache.song = game.add.audio(level.song);// Phaser.Cache.getSound: Key "pixel_world" not found in Cache.Do you know how I can get this to work, or any other way to ensure that the three songs are not loaded at game startup? Thank you!
  17. Hi Everyone, I've got a game with falling snow, but it would be nice if the snow was already falling when the game starts. Right now it starts with a dark sky and then the snow starts falling. In Unity I believe that is an option called Preload(ed) for their particle system. I just noticed the Particle Storm plug-in is available--maybe it has this feature. Can someone give me any advice!? Thanks so much for such an awesome framework and community.
  18. Hi, I'm having trouble with TypeScript when trying to create a custom preloader function/graphic does anybody know a solution please? thanks j class Main { // onFileComplete can't find this function myLoadUpdate() { console.log("myLoadUpdate"); } preload () { this.game.load.image("star", "assets/star.png"); this.game.load.onFileComplete.add(this.myLoadUpdate, this); // => Uncaught Error: Phaser.Signal: listener is a required param of add() and should be a Function. }}
  19. Calling game.load within create

    Hi, Is it possible to preload assets within a state's create() function? I'd like to preload some stuff for the following state during gameplay in order to reduce load time, but when I attempt this, I get the following error: Phaser.Loader - aborting: processing queue empty, loading may have stalled Thanks!
  20. Scaling sprites as they are preloaded

    Ohaio, I'm making a game with a pixelated aesthetic and want to know if I can scale sprites as they are loaded into the game in the preload function. I've created all my pixelart at pixel level but want them to appear in game at 3 times the size. I'm aware that I can scale objects afterwards in the create function however it'd be preferable to scale beforehand to minimise the amount of code needed. I also tried scaling groups of objects but this made the positioning relative to the world very messy. The last method, which I know is the simplest, is to scale all of the pixelart before loading it into the game however if its possible to keep the assets as small as possible that'd again be preferable. Another problem I've had with scaling is trying to disable the smooth scaling that appears to be default. Many Thanks
  21. State preloading assets issue

    Hello guys, I have a bit of an issue. I am currently testing a simple game. It has the index.html, boot.js, and stage.js. The preload function (to load all the assets) is only found in boot.js. When the player fails, the game is suppose to restart and return to stage.js; however, all i get is a black screen (I can also hear the music restart, so at least i know something is working). This issue seems to be fixed if I add the preload function to stage.js to reload all the assets. It also seems to work if i only change phaser.js to phaser.min.js. So it seems the issue is that when the state restarts, its no reading the loaded assets for whatever reason. However, I don't necessarily understand why these fixes work or find them desirable. In particular, I don't want to add the preload function to stage.js because it slows down the game considerably in mobile applications. The weird thing is that I have a very similar structure in another simple game and that one seems to be working correctly. I don't really know what I am doing different. If you guys can offer any insight, it would be really helpful!
  22. Just published a tutorial for beginners on how to add a loading screen that shows the progress of the asset loading process: http://www.gamedevacademy.org/how-to-create-a-loading-screen-in-phaser/
  23. Freezing on new object

    Hi everyone, I'm noticing refresh freezes when showing items (loaded, but with visible set to false). With freeze I mean that although normally the game works with 60fps, when showing new item (loaded but not visible) it takes 300ms to call another render. My loop is simple and looks like the following: function render() { update(); renderer.render( container ); // render stage requestAnimationFrame( render );}I logged the render function to output time from the previous render and it returns 300ms when the problematic event occurs. I tested every single line and it came down to a single line: sprite.visible = true;This sprite is made visible through keyboard event (when space is pressed) and it is the single line of code being called. The texture for the sprite is loaded at the beginning by using PIXI.loader with event complete that instantiates the sprite object, closes the loading screen and shows the stage (container object, I'm using pixi 3.0.6). As follows: PIXI.loader.add("mysprite","sprite.jpg").once('complete',function(){ sprite = new PIXI.Sprite( loader.resources.mysprite.texture ); sprite.position.set( 100, 100 ); container.addChild( sprite );}).load();So why does it take so much time to render the object, it is loaded just not visible. Is there a workaround, like preloading (am I not doing that already?), I mean, this 300ms freeze is just too noticable. One more thing. It happens only on the first time the sprite is shown, later everything runs smoothly. I am testing with Chrome 43 (I tested the example with Chrome 43, IE11 doesn't seem to have a delay), same thing happens on Android after compiling with CocoonJS. Thanks.
  24. Preload assets inside plugin

    Hi! I am writing a plugin that will show some images (needed for UI). I would like to be able to preload all assest needed for this plugin when the plugin is added/activated to the code. I have tried to use preload functionality of GameState inside the plugin contructor, but I doubt it's the correct way. How do I do that correctly? Thank you.
  25. Preload With External Loader

    Hey all, I've been searching but not really finding an answer. The PixiJS Asset loader says: "Once the assets have been loaded they are added to the PIXI Texture cache and can be accessed easily through PIXI.Texture.fromImage() and PIXI.Sprite.fromImage()" So if I want to use an external loader, is it cool for me to stick things in the cache myself? Maybe like this: PIXI.TextureCache[textureName + '-' + i] = texture;? Thanks!