Search the Community

Showing results for tags 'update'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


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

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 74 results

  1. Hi, I'm writing a class that extends Phaser.Weapon and i want that the method update() keep running, like this: class MissileWeapon extends Phaser.Weapon { constructor(game: Phaser.Game){ super(game, game.plugins); } update(){ /*this not execute*/ } } But it not running. If i add this "hack": class MissileWeapon extends Phaser.Weapon { constructor(game: Phaser.Game){ super(game, game.plugins); /*the hack*/ = true; /*active plugin*/ this.hasUpdate = true; var test = game.plugins.add(Phaser.Weapon); /*Only for the game.plugins(PluginManager) start running*/ game.plugins.plugins.push(this); /*add my weapon in the PluginManager*/ } update(){ /*executing */ } } It seems that when extends of plugin Weapon, it not is added direct in the game.plugins (PluginManager), then the method update not executes. How could i make this without uses the "hack"? and i'm using Phaser version 2.6.2 thanks :-)
  2. I'm new to BabylonJS but one of the first things I notice is that almost all of the demos run slow (20-30 FPS is typical) on the same machine that is running three.js stuff fast. It seems like update/draw is not being called as often as it could be, as according to the debug overlay update and draw frame time is only 10ms in these same demos (so potential FPS is 100). Additionally I think BabylonJS suffers from timing flaws that other JS engines do, see this article: In three.js I am using Mainloop.js to control update/draw timing logic. I think I would like to do the same in babylon.js, unless I am missing something. To expand further, physics should ideally be at a 30hz update rate in my game, but draw calls and other update logic should be at 60hz. Also update logic should be called at a very consistent 60hz, where draw can vary a bit from 40-60fps without real harm. (Draw lag spikes are permissible but update lag spikes should be dealt with by calling update twice to catch up and make game logic and especially physics have predictable behavior and equal time per step.) Is there a way without forking Babylon to override the update/draw timing logic? I notice the functions beginFrame() and endFrame() are public. Can I just call beginFrame, do my render calls, and then call endFrame? Will this break anything? What should "do my render calls" look like? Again I would prefer to not modify babylon.js itself, and instead just override its behavior because I don't want to maintain a fork.
  3. Hi all, I'm trying to create a coin counter in my game, using a bitmap font. Everything displays fine, and the counter works, however when a player collects a new coin, rather than replacing the '0' with a '1', it shows a '1', but underneath you can still see a '0' visibly. I've tried several work around methods, including even doing an if statement checking how many coins and replacing it with plain text rather than replying on the var count, and using coinText.updateText();. Does anyone have any ideas? I'll leave my code sample below. var crystalCount = 0; var coinText; //Skip down to the update section coinText =, 10, 'carrier_command', "Crystals:" + crystalCount, 12); coinText.updateText();
  4. So i read it somewhere a few days ago the playground were open sourced by some individuals. I take a closer look at the code, i found at github. Now the question: So the half of it is missing. The Paths to the single source files needed are changed I think it is a good idea to make pull a requst first were all paths pointing again to ??? and the do the hard stuff like, change buttons, ui, add new presets... textures. i think this is a difficult question. becourse the playground is running on a different server for now. and when i start to remap the paths back to babylonjs, its kind of counterproductive.
  5. So I have a group, and it has three sprites. create() { var parent =; var allSprites = [ 'sprite1', 'sprite2', 'sprite3']; for (i=0; i<3; i++){ childImage = parent.create(, (i*30), allSprites); childImage.anchor.setTo(0.5, 1); childImage.inputEnabled = true; childImage.input.useHandCursor = true; } } How to I trigger function changeText(); when one of the child sprite is clicked. So far I have tried this method below but it only detects click on the last sprite. update(){, this); }
  6. Dejan

    Picking updated mesh

    Hi guys, I have a problem with mesh picking and it is a specific case. When I create a ribbon like this, I can see it on the scene: var someRibbon = BABYLON.Mesh.CreateRibbon("ribb", [[new BABYLON.Vector3(0, 0, 0), new BABYLON.Vector3(10, 0, 0)], [new BABYLON.Vector3(0, 10, 0), new BABYLON.Vector3(10, 10, 0)]], false, false, 0, _scene, true, BABYLON.Mesh.FRONTSIDE); On mouse down I am writing the name of the picked mesh in the log: handleMouseDown: function(event){ var pickResult = _scene.pick(_scene.pointerX, _scene.pointerY); var pickedPoint = pickResult.pickedPoint; console.log(; // writes ribb when I click on it } BUT, when I update the ribbon mesh after creation, like this: var someRibbon = BABYLON.Mesh.CreateRibbon("ribb", [[new BABYLON.Vector3(0, 0, 0), new BABYLON.Vector3(10, 0, 0)], [new BABYLON.Vector3(0, 10, 0), new BABYLON.Vector3(10, 10, 0)]], false, false, 0, _scene, true, BABYLON.Mesh.FRONTSIDE); someRibbon = BABYLON.Mesh.CreateRibbon(null, [[new BABYLON.Vector3(0, 0, 5), new BABYLON.Vector3(10, 0, 5)], [new BABYLON.Vector3(0, 10, 5), new BABYLON.Vector3(10, 10, 5)]], null, null, null, null, null, null, someRibbon); Then I can see that the ribbon that is updated (moved 5units along z axis), but it can't be picked. Actually, the picker "thinks" that the ribbon is still in the old position. Does someone have any idea how this could be solved?
  7. Hi guys, I was trying to make a group of objects and got the following error: phaser.js:45776 Uncaught TypeError: Cannot read property 'length' of undefined Everything seems to be fine, anyone has a clue why this might be happening? FYI: I'm using Phaser 2.5.0 Thank you for your help.
  8. Now I meet a problem:I do many things in my create() function,so when the game logic enters into the update() function,the create() function have not been executed completely,but in update() function , it will use something in create(),so it causes problems,is there a way to avoid this by setting up a delay time for update(),let it to executed after function create() has been executed completely?
  9. Check out BlockTanks, a simple yet addicting MMO Tank Game made with nodeJS and Websockets. In BlockTanks, you move a tank and shoot players on the opposite team, getting as many kills as you can. No need to create an account, just type in a name and play! The game's features include: Real time player combat A maze-like map that two teams of tanks can navigate through Four types of power-ups Chat features Tank Skins I made a post about this game a few weeks back, and I have been working on the game since. Here are the new features: By popular request, I've made an invincibility power-up that lasts for ten seconds. The map changes every day to keep the game interesting. I have added more tank skins, along with a list of all the current working tank skins. Server bugs have been fixed to reduce server crashes. A respawn timer has been added and the kill count at the top has been redesigned. Play the game at: Hope you like it! Also, if anyone has any tips/experience with promoting and marketing a game, I would be glad to know UPDATE: BlockTanks now has a bot feature which allows for single player gaming when no one else is online (which occurs often ). If you log on and there is no one else online, a bot will spawn on the other team and fight against you until someone else joins. Please give it a try and let me know what you think of the new AI!
  10. I am getting the following gamepad exception. babylon.max.js:39351 Uncaught TypeError: this.babylonGamepads[i].update is not a function Gamepads._checkGamepadsStatus @ babylon.max.js:39351 Gamepads._startMonitoringGamepads @ babylon.max.js:39340 Gamepads._onGamepadConnected @ babylon.max.js:39304 Gamepads._onGamepadConnectedEvent @ babylon.max.js:39276 For purposes of what I am doing, while I do have a gamepad connected on my system, I could care less about gamepad features. I do not use a game pad at all for this. That I know of, this just recently started happening, or is intermittent, with the one or two couple of version(s).
  11. Hello, We updated the Sublime Text plugin for Phaser with the last Phaser version (2.4.7). With this plugin you get Phaser API code completions.
  12. Hi guys! I have a tube mesh, created with an array of Vector3 points. I update this tube mesh adding new points to the path, but for some reason it's giving me errors like Uncaught TypeError: Cannot set property '0' of null Uncaught TypeError: Cannot set property 'x' of undefined What am I doing wrong?
  13. Tilt The Dot (Android Game) This is my first Android game made with the phaser framework called Tilt The Dot. To play, tilt your device to move a little dot on the screen. Move the dot to hit the blue goals. How high can you score? The game currently consists of 9 characters, a leaderboard, and arcade style graphics. Since the last update, I have added several new and improved features including: - A more comprehensive tutorial - New character! (Dog) - Adjustable device sensitivity - 3-second countdown before gameplay Play it on Android here: Hope you like it!
  14. Hi everyone, I'm developing a simple game where objects visually approach the screen and you have to click on them before they visually reach the screen. However, I was getting mad when trying to add tweening to the sprites representing the approaching objects. They should fade out and in when hit to give a visual feedback to the player that they've been hit. I tested tweens in an extra stage and everything worked fine, so I adapted those three lines of code to the hit callback in the gameplay stage of the game. The tween wouldn't start at all. Before the first time the tween's start function was invoked, its startTime attribute was set to null, after that it changed to 0, but visually, nothing happened. So I wondered if I missed something, commented out all the stuff that could interfere like the content of the update function, where the scale of each approaching object is adjusted and so on. In the end, I had an object with a hit function, a click callback and a sprite, still standing. And still - nothing happened. So just before I wrote this post right here, I tried commenting out the whole update function, including its declaration, from the stage and voilĂ . The tween works like a charm. So to sum up, tweening a sprite doesn't work when an update function is present in the stage to which the sprite belongs. Is this behaviour intended? Is it to fix in a coming release? What is the best practice so far? Greetings, Roberto
  15. Hi there. I have a noob question... How I can update bounds of nested sprites? For example: I have a sprite levelSprite =, 0); //now width and height - 32x32This sprite has two childs levelNum1 =, 0, 'game_assets_4');levelNum1.frameName = "gm_level_number_0001.png";levelNum2 =, 100, 'game_assets_4');levelNum2.frameName = "gm_level_number_0002.png";levelSprite.addChild(levelNum1);levelSprite.addChild(levelNum2); // now width and height still 32x32... why? I use phaser v. 2.4.3 Would you be so kind to help me please...
  16. Hey guys, just a quick one.. Could anybody recommend or argue against putting:"z");Inside the update loop. I have lots of groups that have constantly changing z values. Just curious to see how others do it Thanks Nick
  17. Hello everyone, I'm back again with a question. I have a scene (see screenshot below) that is static after the construction has finished. I want to render shadow once after the construction. I tried "renderTargets" off. But the shadow sometimes disappears. I would need something like a shadowgenerator manual mode. So like "calculateShadow" and then it keeps this shadow map until the next "calculateShadow" call. Is there something like that or an easy way to achieve that? I think this is something useful for other users too. Have a nice day, Kevin
  18. So i've recently been building a game in Phaser, trying to keep objects as modular as possible, which lead me to this question. I have a main game state that currently handles all input events and moves / mutates objects as necessary, e.g. player, enemies, particles, etc, each being a modular object which is required using browserify. I wanted to keep all input handling / updating within this function to reduce the function calls I'm making each frame (to reduce delta times). My question is, would this actually yield noticeable efficiency improvements, or should I just pass a reference to the game object to each module to handle their own input / updating. Considering objects pass by reference, this shouldn't be an issue right? FOR EXAMPLES SAKE, So basically instead of update: function() { game.physics.arcade.overlap(enemyBullets, tank, bulletHitPlayer, null, this); enemiesAlive = 0; for (var i = 0; i < enemies.length; i++) { if (enemies[i].alive) { enemiesAlive++; game.physics.arcade.collide(tank, enemies[i].tank); game.physics.arcade.overlap(bullets, enemies[i].tank, bulletHitEnemy, null, this); enemies[i].update(); } } if (cursors.left.isDown) { tank.angle -= 4; } else if (cursors.right.isDown) { tank.angle += 4; } if (cursors.up.isDown) { // The speed we'll travel at currentSpeed = 300; } else { if (currentSpeed > 0) { currentSpeed -= 4; } } if (currentSpeed > 0) { game.physics.arcade.velocityFromRotation(tank.rotation, currentSpeed, tank.body.velocity); } land.tilePosition.x =; land.tilePosition.y =; // Position all the parts and align rotations shadow.x = tank.x; shadow.y = tank.y; shadow.rotation = tank.rotation; turret.x = tank.x; turret.y = tank.y; turret.rotation = game.physics.arcade.angleToPointer(turret); if (game.input.activePointer.isDown) { // Boom! fire(); }}I'd have something like update: function() { this.tank.update(; this.turret.update(, this.tank); this.shadow.update(, this.tank); // etc etc}
  19. I have a scene that I update every frame by calling scene.render(). I want to be able to run all the scene calculations, but without drawing to the canvas. How can I update the scene without telling it to draw to the engine's canvas?
  20. In my memory game there are two loop timers, one which runs on each 100 milliseconds and second on each 1000 milliseconds. We cannot forget also the update() function which comes along the Phaser.State class. In the 100 mil timer I do stuff like replacing cards by position, and showing helper arrows. On the 1000 mil timer I just increment the clock by one second. All works well but the code got kind of too cluttered so I am afraid, I could break something at this point. For best performance, is it good to use only one timer and no update() method or should I just move all in update() method and count the number of frames passed?
  21. Hi, doc for exists property in Phaser.Group reads: "If exists is true the group is updated, otherwise it is skipped." But when I look into preUpdate(), update() and postUpdate() source, this property is taken into account only in preUpdate() method. Is it intentionally or is check for exists value missing in update() and postUpdate() methods?
  22. Hi, I'm new to HTML 5 game dev and maybe the next question is very easy for the experienced but I can't seem to find a good solution, so don't shoot. The question isn't strictly related to HTML 5, it is more like a generic question for every platform. For the sake of simplicity, we are given: one update timer that runs 4 ms in its own thread, one render timer that runs 10 ms in its own thread. Usually, game's loop clears the entire screen before the render operation, but we all know this is not always a solution for games when going javascript and/or mobile. So, there are games (e.g. tetris) where we need to handle states of objects (that may move or may not move). The most efficient loop for such a game is to: draw the current moving brick without redrawing the entire screen, wait a second and DO NOTHING, then delete the area of the old brick ONCE, update the brick position ONCE, draw the brick ONCE. I have written the capital words because I can't find a solution for handling these situations. And now the questions start. How do you do such things once in a multi-threaded environment without spamming these operations ? Assume that a new brick is created at uf 1 (uf = update frame), i send it to be rendered, so I do nothing on uf 2 (I have to wait a second). Since rf 1( = render frame) happens after uf 2, how do I remember to draw from uf 1 rather than uf 2 (because uf 2 contains no changes). You may say to keep them in a list of "drawables" and just render that list. But what if uf2 actually contains changes ? Using the above list, i would have a list like [delete uf 0, draw uf 1, delete uf 1, draw uf 2] sent to render. This is not very efficient. You may say to reduce this list by removing opposite commands like "draw uf 1" and "delete uf 1", and only have "delete uf 0" and "draw uf 2". This may also take some serious time to compute every possible combination of reduction, but i may be wrong here. Besides that, doesn't that constitute a danger to other objects that may overlap my "state" object ? like not being displayed properly or being cut but by the "delete uf 0" which is an old state when render happens. Do you have an efficient solution for this ?
  23. I'm trying to update properties on tiles within a tilemap layer once the player has moused down on a tile. When I try this though, my tiles never get updated. I tried the following as a basic test where I directly update a single tile in the layer all of the time to make sure that the update was working and this works correctly. function update(){ foobar = bg_map_layer.getTiles( 14,113, 1, 1); foobar[0].alpha = 0.5; foobar[0].rotation = 40;}So here I'm trying to update the tiles in update after they have been moused down on... function update(){ if(game.input.mousePointer.isDown){ mouseX = game.input.mousePointer.x mouseY = game.input.mousePointer.y if ((mouseX > 867 && mouseX < 74) && (mouseY > 77 && mouseY < 72)) { play_button.x=867 play_button.y=77 } arr_touched_tiles = _.union(arr_touched_tiles, bg_map_layer.getTiles( 300,300, 100, 100)); arr_touched_tiles = bg_map_layer.getTiles( game.input.mousePointer.x, game.input.mousePointer.y, 10, 10); } for(var i = 0; i < arr_touched_tiles.length; i++){ arr_touched_tiles[i].alpha = 0.0; arr_touched_tiles[i].rotation = 40; } }On this second version I never see the tiles change. When I try to inspect it in the browser console it gets into my for loop and the values appear to be set on the tiles, but they do not display with the alpha + rotation.
  24. I'm aiming towards having a small text panel on the left hand side of the screen which contains data pertaining to my sprites (position etc). I wouldn't know how to set live updating text in Phaser though. I made this little sandbox to help explain: Where I have the text "circle position" is where I would like live updates of the circle's x and y position [ example: game.add.text(10, 32, "x: " + sprite.x, style); ]. The circle is draggable, but I'm not sure how to access and display the positional values for a sprite in real time. Any help much appreciated. Many thanks in advance.
  25. In my game, i have a timer event which will run for 60 seconds. This is a startGame function in coffeescript. Which has a time event in bold letters. I passed @seconds_counter value which is 60. So this timer will count till 60 seconds and afterthat calls @removeCounter function. startGame: -> left_button = @add.button(60, 350, 'button', @checkAnswerForLeft, this) right_button = @add.button(460, 350, 'button', @checkAnswerForRight, this) @timer # Start main game counter @seconds_timer =, @updateSecondsCounter, this) Phaser.Timer.SECOND * @seconds_counter, @removeCounter, this In my game i want to give users a time bonus in which i want to add extra seconds to this time event. I added 10 seconds to @seconds_counter but it won't affect this timer event. So in short, my game loop is 60 seconds. If user get time bonus then add 10 seconds to game loop so for that user gae will be of 70 seconds and after that @removeCounter function should call. Is there any way to update time for running timer??