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 31 results

  1. 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! :-)
  2. 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?
  3. 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.
  4. 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?
  5. 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
  6. 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
  7. 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?
  8. 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
  9. 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!
  10. 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?
  11. 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!
  12. 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!
  13. 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.
  14. 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. }}
  15. 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!
  16. 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
  17. 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!
  18. 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/
  19. 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.
  20. 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.
  21. 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!
  22. Hi, another question about performance~ I've been busy updating my code to get more performance out of Phaser and CocoonJS. Currently everything runs fine ( stable 55 - 60fps ). Question / Problem When I change States - for example I go from my titlescreen into the mainmenu State: there are a few sprites set up and a few tweenings are done. A few means 3 - 6. During the change into the state the game struggles a little bit - it is lagging and also the tweening is lagging. This happens on all iOS devices (only developing for iOS included normal resolution screens / retina devices / iPad Air). The images which are loaded, the audio and all the stuff is minimzed and optimized. There are no big file sizes which have to be loaded. A few Questions on it - Is there something like a preload for tweens? - Or can I preload a state or something? - Which other issues cause this? All the stuff is preloaded in the "preload" function. My states (example: titlescreen, mainmenu) are out of the "create" function - as an own state, is that correct? because to call everything into the create function themes a little bit overdue - to call an entire game with all the logic etc on start. Any suggestions / improvements?
  23. Sequential loading

    Hi, I've recently started work on a platformer where level information is stored in json files. However I can't see a way to load all the files nessecary without having multiple states. Essentially my issue is that I have a Level Data file which, amoungst other things, contains the filename of a tilemap file, this tilemap file contains the filename of the tile image. I need all these files before the game itself can start. Is there a way in phaser to seqentially load these files, ideally in the preloader phase of a state? If I haven't made this clear enough please ask questions. Thanks, Miniscoggs
  24. Audio + CocoonJS Preload Problem

    // Audiothis.game.load.audio('bgMusic' , 'assets/audio/DST-Blam.mp3');this.game.load.audio('splashSFX' , 'assets/audio/Kayyy-Wave.mp3');this.game.load.audio('sparkleSFX' , 'assets/audio/Sparkle-Robinhood76.mp3');this.game.load.audio('gameOverSFX', 'assets/audio/Benboncan-SadTrombone.mp3');So this is the code in my preload to load audio. When running it in CocoonJS Launcher app on Android I get the following warnings in this order: Phaser.Loader error loading file: gameOverSFX from url null Phaser.Loader error loading file: sparkleSFX from url null Phaser.Loader error loading file: splashSFX from url null Phaser.Loader error loading file: bgMusic from url null Running the game through a localhost loads the audio perfectly fine which is what I find odd. Anyone have any idea?
  25. Preload Future States in Create?

    I'm a first time user of Phaser, been trying to make a simple point and click type game. I'm trying to keep things very modular, so I'm defining a list of levels (states) in a JSON, and then every level has its own JSON containing the objects within that level. However, I'm encountering an issue in that, when changing states, I get a black flash while the assets for the next state load (this happens whether I iterate through the JSON list or define everything manually). From what I've read, all sprites should be loaded in the preload stage, however, by doing this I'm causing that tiny but noticeable black pause. I know one way would be to simply load every asset at the start of the game, but that seems incredibly inefficient (wouldn't that fill up the memory immensely?). I would rather load a state's assets from the "parent" state. However, in my quick test (which maybe I did wrong) it seems that game.load doesn't work properly if done within the create stage? What is the best approach to doing this?