Jump to content


  • Content Count

  • Joined

  • Last visited

About Cutu

  • Rank
  • Birthday 12/10/1991

Profile Information

  • Gender
  • Location

Contact Methods

  • Twitter

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hey @phreaknation thanks for your answer, I already fixed the problem, I had to delete this line pointBlocks.body.enable = false; in my overlap callback, because when it calls the reset method in the createWall function the sprite has no body and stay stuck in the top, anyways thank you!
  2. Hey guys its me again, I'm having some issues recyling objects when calling the kill() method. As you can see in the gif I call the kill() method after the player overlaps with the invisible blocks adding 1 point to the score. the problem is that when they're dead they respawn and stay on top of the screen and after the pool of invisible walls is over the game get stuck giving a "Cannot read property 'reset' of null" because they get stuck. This is the code of the walls. //Create this.walls = this.game.add.group(); this.walls.enableBody = true; this.walls
  3. Hey @samme thanks for your answer, I already solved my problem this way: addWall: function(x,y,point) { var wall = this.walls.getFirstDead(); wall.reset(x,y); wall.body.velocity.y = this.wallSpeed; wall.body.immovable = true; wall.checkWorldBounds = true; if(point == 0) { //Added this so it will trigger with the first block in every row and not every block. wall.events.onOutOfBounds.add(this.incrementScore, this); } wall.outOfBoundsKill = true; }, addWallRow
  4. I tried that but the callbackFunction triggers every frame so it never stop adding 1 to score :/
  5. Hey guys, I'm making this game where you have to go through the hole in the walls by moving the ship left or right. What I need is to increment the score everytime you pass through one hole. The walls are a group of blocks that spawn every 1 second with a timer. I tried to increment the score using group.getFirstAlive() and checking if the Y position was higher than the player's one but the problem is that every row of blocks spawn each second and the group.getFirstAlive() takes only the first child until it dies and when it dies the other 2 or 3 rows that spawned before won't increm
  6. Hey! I'm learning phaser too and I'm not sure if this is the solution but it might go like this: game.input.onDown.add((function(e) { if(e.position.x <= 128) { player.body.velocity = -velocityy; player.animations.play('left'); return; } else { player.body.velocity.x = velocityy; player.animations.play('left'); return; } } )); <-- I missed this after the last }, I hope this help you!
  7. You mean using body.position instead of velocity? I didn't tried that because I was following one of those flappy bird tutorial, but now I tried and if I use the position in the touch events the sprite won't move I don't know why. What I just did it was to add another property to the player "xMove" to use it with the keyboard inputs and the xSpeed with touch inputs like this: //Touch Inputs this.game.input.onDown.add((function(e) { if(e.position.x < this.game.width/2) { this.player.moveDirection = -1; } else { this.player.move
  8. Ohh I see, thank you so much for your help, but now I have one last question, in the Update method I have the movePlayerCursors which moves the player Horizontally using the left and right keys, this works properly but it makes conflict with the touch inputs because I had to set the player.body.velocity.x to 0 making the user tap like crazy to move the player sprite, but if I don't set this velocity to 0 when they use the keyboard inputs the sprite won't stop moving, I'm sorry if its difficult to understand but English is not my native language, if you can help me with this I would appreciate
  9. Thanks @Théo Sabattié, I tried before binding this to the object but it didn't work (got a "bind is not a defined method" error), but now that I saw your suggestion I noticed that you added the callback inside parenthesis, what's the difference? This was how I did it, and one last question which object does it refers when we bind "this"? The Main object? This was how I did it and didn't work: this.game.input.onDown.add(function(e) { if(e.position.x < this.game.width/2) { moveDirection = -1; } else { moveDirection = 1;
  10. Hey guys this is a quick question, I was trying to make an sprite move left or right with the input.onDown/Up() event, but I'm getting "Cannot read property 'body' of undefined. Here's the code of my Main state. var xSpeed = 600, moveDirection = 0; var Main = function(game) { }; Main.prototype = { create: function() { this.createPlayer(); //Testing if it works on PC and it does. this.cursors = this.game.input.keyboard.createCursorKeys(); //Added the touch events (So it can be played in mobile devices) and it doesn't work :(
  11. @rufflezs thanks man, I did it but now I'm getting '"barrier" is undefined' in the scoreSystem() function, I can't make it work :(. Thanks anyways I'll keep trying, if you think in any other solution please let me know.
  12. I tried that but I get "cannot read property 'scored' of null" when the scoreSystem() is triggered. this is it: function scoreSystem(barrier) { if(!barrier.scored && barrier.y >= spaceship.world.y) { barrier.scored = true; score += 1; Math.round(score, 0); scoreText.setText(score.toString()); } } I hope you can help me plz.
  13. Thank you Claudio, I already did it, but now what I need is to check if the whole group Y position is greater than the spachip one. How can I do that without using the forEach method? When I use forEach it checks every block and add +1 to the score making a total of 6 per row. I need to add just 1 point, not 6.
  14. Hi, thanks for answering guys, as Claudiovc said that's my problem and I know it, that's the point of the topic, but my question was if can I add the property "scored" or "letsgo" to my barrierGroup instead of every Barrier is created so I can do something like everytime a new group is made their "scored" property by default is false but when the row position is greater than the ship position add 1 to the score and set the "scored" property to true and repeat the loop? I have tried something like barrierGroup.position.y but doesn't work x.x I tried your suggestion, but its not working how
  • Create New...