Search the Community
Showing results for tags 'postupdate'.
-
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.
-
Hi, I've been working a bit on getting some speech bubbles over my player and while the positioning is fairly straightforward I have run into alot of issues that makes me feel I have no clue what the heck I'm doing, so I thougth I'd ask some questions regarding update functions here. 1) When I create my player as "game.add.sprite(0, 0, null);" and add a postUpdate function to it, it completely stops moving. Why is this? 2) When I have have a speech bubble defined as "game.add.sprite(0, 0, null);" and add a postUpdate function to it, things work just fine. What is the difference here? 3) Inside a postUpdate on my speech bubble I do some math to calculate proper positions of child elements. I have no issues with getting the position of the child elements right, but since the player position is a float rather than an integer my tilemaps for the sides gets distorted. I thought I'd fix this by compensating the speech bubbles coordinates by taking the fraction form the parent (the player) and removing it form the speech bubbles position. For some reason this des not seem to apply properly and my speechbubble stutters back and forth. In what order do the preUpdate, update, postUpdate functions happen? // Create a new player.game.players[player_id] = game.engine.add.sprite(start_x, start_y, null);// Enable physics emulation for the playergame.physics.arcade.enable(game.players[player_id]);// Add a thought bubble..game.players[player_id].thought_bubble = game.engine.add.sprite(0, 0, null);game.players[player_id].addChild(game.players[player_id].thought_bubble);// Keep the text and orientation proper on every frame.game.players[player_id].thought_bubble.postUpdate = function(){ var offset_x = (this.world.x - Math.round(this.world.x)); var offset_y = (this.world.y - Math.round(this.world.y)); this.y = 0 - offset_y - Math.round(this.bg.height / 2) - 50; this.x = 0 - offset_x;}