Search the Community
Showing results for tags 'empty'.
-
Hi Phaser Devs, I'm having trouble with something in the game I am currently creating. The concept of the game is that circles randomly spawn on the screen and begin to grow in size, this I have achieved using a tween object to scale the sprite. However the game is about taping the circle to get points, the bigger the circle the more points you get, but if two circle collide then it's game over. The problem I'm having is checking to see if the space where the circle wants to spawn is free, otherwise it would spawn on an existing circle causing the game to just end even though the player had no chance of preventing the loss. I have a group created which contains 20 circle sprites. I then after a set amount of time get the first dead circle in the group set its scale to 0 and reset its x and y position to a random place on the screen, then starting the tween to make the circle grow. However I can't figure out how to make sure the x and y positions are not already filled with a circle and if it is then randomly create the x and y positions again. Is there any way to do this using phaser? I did think that maybe creating an array to keep a log of the circles on the screen as well as their x, y and scale them using custom maths to work out if the x and y position has been taken or would be by the time the circle has spawned. Although I thought that if phaser has a similar feature built in it might be a much faster method. Thanks everyone in advanced, this is really making me pull my hair out .
-
I wrote an edit box in Phaser which is working perfectly apart from one detail. When I try to delete existing text and enter a new string, it cannot delete the first character. After some poking around I found it is due to this code being carried over into Phaser: PIXI.Text.prototype.setText = function(text){this.text = text.toString() || ' ';this.dirty = true;};When I delete the last character in a string then try to assign the now empty string to the Text.text field, it is being replaced with a space. Apparently this was to prevent a PIXI crash when an empty string was encountered... but maybe that's been fixed now? Is there a reason why I shouldn't try to fix this by using '' instead of ' '? Empty strings are normally quite acceptable, but perhaps there's something deeper inside which I haven't spotted yet. I've already changed Phaser and it seems stable with the change, but as Phaser likes to mimic PIXI when functions are duplicated/similar I probably can't get that into the main branch without a similar change to PIXI.