• 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.walls.enableBody = true; this.walls.createMultiple(250,"wall1"); this.wallSpeed = 250; this.wallsDelay = 1000; this.timer =, this.addWallRow, this); //Update, this.pointBlocks, (function(player,pointBlocks) { pointBlocks.body.enable = false; pointBlocks.kill(); this.score += 0.5; this.scoreText.setText(this.score.toString()); }).bind(this)); //And the create methods of the walls addWall: function(x,y,immovable) { if(immovable) { var wall = this.walls.getFirstDead(); } else { var wall = this.pointBlocks.getFirstDead(); } wall.reset(x,y); wall.body.velocity.y = this.wallSpeed; wall.body.immovable = immovable; wall.checkWorldBounds = true; wall.outOfBoundsKill = true; {wall.kill(); console.log(wall.exists);}).bind(this)); } addWallRow: function() { this.wallSpeed += 5; var tilesNeeded = Math.ceil( / this.wallWidth); var hole = Math.floor(Math.random() * (tilesNeeded - 3)) + 1; for(var i=0;i<tilesNeeded;i++) { if(i != hole && i != hole + 1) { this.addWall(i * this.wallWidth, 0, true); } else { this.addWall(i * this.wallWidth, 0, false); } } } I hope you guys can help me with this one! Thanks in advance!
  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., this); } wall.outOfBoundsKill = true; }, addWallRow: function() { this.wallSpeed += 5; var tilesNeeded = Math.ceil( / this.wallWidth); var hole = Math.floor(Math.random() * (tilesNeeded - 3)) + 1; for(var i=0;i<tilesNeeded;i++) { if(i != hole && i != hole + 1) { this.addWall(i * this.wallWidth, 0, i); } } This is working fine because it add exactly 1point every time the row of blocks go out of bounds so I had to move the player position a bit lower in the screen. I tried overlaping the player with the hole (by adding 2 invisible blocks in that area) but the callback triggered like 50 times but maybe because I didn't disable its body, I'm gonna give it a try anyways! Thank you! Edit: @samme I already tried your suggestion but since I have 2 invisibles blocks it adds 2 points instead of 1 if the player overlap just in the middle (because it hits both blocks) and I can't add 0,5 points because sometimes the player won't hit both blocks :/
  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 increment the score. So I thought that I could increment the score by creating and invisible group of blocks below the player and use the collision handler to increment the score everytime both walls overlap. This is the code I'm using currently:, this.walls, (function(){ this.score+=1; this.scoreText.setText(this.score.toString()); }).bind(this)); The problem with this is that when the walls overlap the score doesn't increment by 1 but by 300 or the number of blocks in each row of pointBlocks(the invisible ones). Is there a way to just increment the score by 1?? Thanks in advance! And sorry for my English.
  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;'left'); return; } else { player.body.velocity.x = velocityy;'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 { if(e.position.x < { this.player.moveDirection = -1; } else { this.player.moveDirection = 1; } this.player.body.velocity.x = this.player.xSpeed * this.player.moveDirection; }).bind(this)); { this.player.body.velocity.x = 0; }).bind(this)); //Keyboard Inputs movePlayerCursors: function() { if(this.cursors.right.isDown) { this.player.body.position.x += this.player.xMove; } else if(this.cursors.left.isDown) { this.player.body.position.x -= this.player.xMove; } } //And the createPlayer function createPlayer: function() { this.player =,*0.8, "player"); this.player.anchor.setTo(0.5, 0.5);; this.player.checkWorldBounds = true; this.player.body.collideWorldBounds = true; this.player.xSpeed = 500; //added this for Touch this.player.xMove = 10; //this one for keys this.player.moveDirection = 0; } I'm not sure if this is how it has to be but it works, still don't know why if I use body.position in the touch event the sprite doesn't move D: Thank you anyways!
  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 it. Thank you one more time @Théo Sabattié this is the part of the code I'm talking about: movePlayerCursors: function() { this.player.body.velocity.x = 0; //If I remove this line the sprite won't stop moving using the right and left keys, but if I leave it there the user will have to tap like crazy the phone to move pixel per pixel the sprite. if(this.cursors.right.isDown) { this.player.body.velocity.x += this.player.xSpeed; } else if(this.cursors.left.isDown) { this.player.body.velocity.x -= this.player.xSpeed; } }
  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: { if(e.position.x < { moveDirection = -1; } else { moveDirection = 1; } this.player.body.velocity.x = xSpeed * moveDirection; }).bind(this); *Notice that I didn't wrap the anonymous function in ( )*
  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 =; //Added the touch events (So it can be played in mobile devices) and it doesn't work :( { if(e.position.x < { moveDirection = -1; } else { moveDirection = 1; } this.player.body.velocity.x = xSpeed * moveDirection; }); //This one is to stop the player from moving. { this.player.body.velocity.x = 0; }); }, update: function() { this.movePlayerCursors(); }, gameOver: function() {"GameOver"); }, createPlayer: function() { this.player =,*0.8, "player"); this.player.anchor.setTo(0.5, 0.5);; this.player.checkWorldBounds = true; this.player.body.collideWorldBounds = true; /*I tried adding xSpeed property to player but it doesn't work neither :/ this.player.xSpeed = 600; */ }, movePlayerCursors: function() { this.player.body.velocity.x = 0; if(this.cursors.right.isDown) { //this.player.body.velocity.x += this.player.xSpeed; this.player.body.velocity.x += xSpeed; } else if(this.cursors.left.isDown) { //this.player.body.velocity.x -= this.player.xSpeed; this.player.body.velocity.x -= xSpeed; } }, }; What am I doing wrong? I hope you guys can help me, thanks in advance!
  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 >= { 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 I want, thank you anyways