Jump to content

Search the Community

Showing results for tags 'Async'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 8 results

  1. This is my async.forEachSeries function: async.forEachSeries(parsed.moves,function(move, callback) { that.moveObj(move, callback) }, function() { console.log('done running the entire code') }); Move object is starting the tween and calling the callback onComplete of the tween. moveObject(x, y, obj,callbackToAsync, offsetX = 0, offsetY = 0) { let coordinates = this.convert(obj.i + offsetX,obj.j + offsetY) let tween = this.game.add.tween(obj, this.game, this.game.tweens).to({ x: coordinates.x, y: coordinates.y }, 2000) tween.onComplete.add(callbackToAsync,this) tween.start() } So from my understanding, each move should be called and after the tween for that move is complete it should call the callback and proceed to the next iteration with the next move in the array. What ends up happening is that the first move is executed and then it goes to the function that should be called when all iterations are done without completing all the iterations. I've made sure that the moves array has more than one object. So this has something to do with the tween, since when I simply call the callback in moveOb it processes the moves sequentially.
  2. Code: https://pastebin.com/zE0zhn7K So if you try to load a scene asynchronously, do something else, start the engine using that scene, The scene will just show an empty space. However, if you take a look at the code above, go to async function createScene(config) { const { textureModifier } = config; const { height, width, color } = config; const scene = new Scene(config.engine); await importScene(config.mesh, scene); And comment 'importScene' line, the go to async function run() { // await importScene(config.mesh, scene.internal); engine.runRenderLoop(() => scene.render()); // engine.runRenderLoop(() => console.log('test')); } And uncomment 'importScene' here, it works fine. I've included a .babylon file below. foot.babylon
  3. Just a quick question; how to not freeze the render loop when doing "heavy" operations? Example: In my game, I have a stage that is composed of squares. The player can move around the stage but so can the enemies. The enemies are using a pathfinding system that uses navigation mesh. This navigation mesh is created dynamically when the game runs. Player can destroy the tiles of the stage. The tile destruction triggers the recalculation of the navmesh. The recalculation itself is a pretty heavy operation that freezes the whole game for a second or so. What I'm pretty much asking is if there is an async functionality for heavy functions/operations that are triggered from the render loop. Or what is the best way to handle these situations?
  4. Hi, To make the preload faster, I need to load several assets after the preload phase, and use then when they has been loaded. To do that, I've used the Phaser.Loader object and register to "onFileComplete" Phaser.Signal to catch the file when has been loaded, to load the next file. This works well until I need to change the current state and there are an asset being loaded. When the file is loaded and the new state has been created, Phaser detects that the Loader is not loading (processLoadQueue method from Phaser.loader) and shows this message: 'Phaser.Loader - active loading canceled / reset', and the "onFileComplete" registered functions, are not fired, and I cannot continue loading more assets. My idea was to attach to "onStateChange" signal and stop/pause the current async download, but there are no public methods in Phaser.Loader to do that. Are there a good way to load assets asynchronously with state changes? Thanks
  5. Hey guys! I am coding simple roguelike dungeon crawler: Live version. I have this issue with collisions, whenever a player is positioned like this: ( the lighter tiles are floor tiles and the darker walls obviously ) When he presses down arrow and left arrow at once, he can move on wall tile. This is how I handle input: onKeyDown( event ){ switch ( event.key ){ case 'ArrowUp': this.nextStep( 0, -1 ); break; case 'ArrowDown': this.nextStep( 0, 1 ); break; case 'ArrowLeft': this.nextStep( -1, 0 ); break; case 'ArrowRight': this.nextStep( 1, 0 ); } } nextStep( playerDirectionX, playerDirectionY ){ if ( !this.canMove( this.player, playerDirectionX, playerDirectionY ) ){ return; } this.player.x += playerDirectionX * TILE_SIZE; this.player.y += playerDirectionY * TILE_SIZE; } canMove( unit, dirX, dirY ){ const targetTileX = ( unit.body.x / TILE_SIZE ) + dirX; const targetTileY = ( unit.body.y / TILE_SIZE ) + dirY; return ( this.map.isInBounds( targetTileX, targetTileY ) && !this.map.isWall( targetTileX, targetTileY ) ); } Here's the whole project's code: https://github.com/pietrzakacper/Roguelike-Dungeon-Crawler/tree/master/src/Game Can somebody help me please ?
  6. I'm building my first Phaser game and stumbled upon a conceptual issue I'm not sure how to solve best. Sometimes I want to wait for a tween to finish before I run the next bit, e.g. in a match 3 game I'd want to remove the matched blocks before dropping the rest and so on. Here's a snippet to illustrate how I've found it done in simple examples. function removeBlocks() { var duration = 1000; game.add.tween(...).to(..., duration, ...).onComplete(...); ...}function dropBlocks() { ...}removeBlocks();game.time.events.add(1000, dropBlocks);This works but there's an implicit dependency between the duration of the tween and the timer and any code run in the onComplete callback will race dropBlocks. The former could be fixed by passing the duration around but that's an implementation detail of removeBlocks that nothing else should depend on. The obvious way to make the dependency explicit is to use the onComplete callback. However, that means either passing dropBlocks to removeBlocks or exposing the tween to add the onComplete outside. Alternatively, one could introduce an onBlocksRemoved event that's triggered in the onComplete callback and add removeBlocks as a one-time listener. That hides the tween completely but feels like abusing the event system if this is the only callback and means writing code in the wrong order: game.onBlocksRemoved.add(dropBlocks);removeBlocks();Instead I'm currently returning a promise. function removeBlocks() { var tween = game.add.tween(...).to(...); var promise = new Promise(function (resolve) { tween.onComplete.add(function () { resolve(); }); });}removeBlocks() .then(dropBlocks) .then(...);I do like this solution a lot more than the alternatives because it hides the tween while making chained events readable but promises are usually defined by resolving to a value which is something I don't have or need. That may be a hint at me misusing promises here. I'd love to hear your opinion on my approach and some open questions / thoughts. 1. Is there an obvious solution that I'm missing because I'm still new to the framework? 2. When I'm tweening several things at once I could use Promise.all to continue once all tweens have finished but that might be me overthinking something simple.
  7. Hey guys, I have just got adverts working in my game, however I have an issue with loading the ad. When I call this function fullscreen1 = CocoonJS.Ad.createFullscreen(fullscreen1Params);It will lock up/lag my game until it fetches the ad. I want to do this asynchronously but I don't know how to tackle this using pure javascript (I am not using a framework that has this built in). Does anyone have tips for how they bypassed this issue? I am tempted to just wait until the complete callback is called however if the ad fails to load then the game will never start. Is there a simple way around this? Thanks.
  8. Hi guys, I need some general advices regarding building a turn-based multiplayer game using HTML5 that runs of Facebook. It would be my first multiplayer game, so please be kind with me It's a sort of "quiz-game" in which you: 1. select a Facebook friend to challenge and 2. answer 3 different questions Then, when the other player has completed his turn, the game will choose the winner. I believe that the server logic it's very simple because it only has to 1. calculate the players' scores on each answer 2. check who's the winner 3. post the scores to a database to build a leader board. I'd like to know which is the best way, the best library or the best tech-stack to build such a multiplayer environment. I need to connect two players to the same game (asynchronously, they don't need to be connected at the same time), having their scores updated by a server (to avoid cheating). I'm looking for something like PeerJS (http://peerjs.com/examples), don't know if there's something more specific. I need a simple solution that works Thanks for you advices
×
×
  • Create New...