• Content Count

  • Joined

  • Last visited

1 Follower

About Zaidar

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  • Location

Recent Profile Visitors

1129 profile views
  • Tef

  1. Hi, I finally decided to give a try to P2 after using Arcade a lot. So I started my project with Phaser 2.0.7, and was trying to build a really simple test with just 1 box falling on top of another one. But it appears in all the examples that without configuration the world should automatically have bounds, which is not the case in the 2.0.7 build. However, when I passed to 2.0.6, just by changing the phaser version, with the same code, the world has bounds. my code : //create functiongame.stage.backgroundColor = '#00ffff';game.physics.startSystem(Phaser.Physics.P2JS);this.ball1 = game.add.sprite(165, 300, 'ball1');this.ball2 = game.add.sprite(150, 400, 'ball2');game.physics.p2.enable([this.ball1, this.ball2], true);// update function this.ball1.body.velocity.y = 50;Sorry if it's documented somewhere, but couldn't find anything on this subject. Thanks in advance for helping.
  2. Zaidar

    Draw an Arc

    create: function(){ = this.add.bitmapData(resolutionGame[0], resolutionGame[1]); this.circleSprite = this.add.sprite(0, 0,; }, update: function(){;, y, radius, angleStart, angle); = '#000000';;; },Something like this should work. I haven't done game dev for few of weeks, so can't remember
  3. I bought the whole thing 100€, but I think it's more interesting for really beginners. If you've already been developing 2 or 3 games with Phaser, I don't think you'll actually learn a lot. I really appreciate the idea of the book, it's just me who had put too much expectation on it. If you're a beginner in phaser I recommend it though. Thx to the author for the time and even if it's not what I was looking for I think you did well (better than I would do, so good job)
  4. You need to put a background, otherwise Cocoonjs just try to fill with the sprite.
  5. Zaidar

    Performance Tips

    PhoneGap isn't great for performance for canvas games. I think it uses the webView from Android, which has quite bad performance. You said you tried Cocoonjs, but did you try on WebView or Canvas+ because Canvas+ is way faster with games using canvas?
  6. Zaidar

    Using Plugins

    Well, since it works and the plugin is part of the game.plugins array, I think that's the good solution.I have an example working for you. Let me put this online. Here is the game, the only part I use the Juicy plugin is for the screenShake effect (I know, but it was just for testing at first, so I just left it here) This is the source on Github : Basically if you look at line 57, I'm adding the plugin into the Phaser pluginManager. And lines 157 and 169 I use the shake() function to make the screen shake. At the end, when you put a red bomb on the black container, it explodes and make the screen shakes. If you have already used OOP for your games, like a Player.js where you define a player "constructor" and player functions, this is the same thing. Plugins could just be inserted in the main code, but at the end of the day, it's just for better clarity and organisation I think.
  7. Zaidar

    Using Plugins

    Yeah, I wasn't sure so I retested, but I confirm it doesn't work if you just do this.juicy = new Phaser.Plugin.Juicy(this);
  8. I don't really understand the problem, but the site is planned to be redesigned soon, so...
  9. I have no idea if it can help you or not, but I know gamedevtuts made a tuto about water couple in January. It's in Unity, but I hope you maybe take some of the concepts here. No idea. I just know that recreating water behavior can be really intense in ressource if you want some level of reality. But the solution brought in the tutorial seems interesting, even if I didn't give it more than a look to the final result, it seemed quite good. TL;DR : Here is the link If you have any new thing on this don't hesitate to keep us to date.
  10. After 20 squares that's normal that you get an error because you use the creatMultiple() function which create a limited number of square. Phaser only create 20 squares, and you're using only these. I recommand you to just create this square one by one. It won't kill the perfs as you're destroying them when they get out of the world. function create() { squares =;// NO MORE CREATEMULTIPLE WE CREATE IN THE ADD_ONE_SQUARE FUNCTION ball = game.add.sprite(365, 470, 'ball'); game.physics.arcade.enable(ball, Phaser.Physics.ARCADE); timer =, add_squares); side = "right"; game.stage.backgroundColor = '#ffffff';} function update() {} function add_one_square(x, y) { // var square = squares.getFirstDead(); // HERE WE CREATE ONE SQUARE EVERY 500s AT THE X AND Y COORDINATES var square = squares.create(x, y, 'square'); game.physics.arcade.enable(square, Phaser.Physics.ARCADE); square.body.velocity.y = 300; square.outOfBoundsKill = true; // Cant figure out where to put this or how to make it work game.physics.arcade.moveToObject(ball, square, 300); }After, the ohter problem of your code, is that the ball goes to the square position but at its creation's position. What I mean is that game.physics.arcade.moveToObject(ball, square, 300); is telling to the ball to move to the point where the square was at his creation. Given that the square is falling down, it looks like the ball doesn't go to the square position. If you really want the ball to go to the current square position, you need to update the ball position given the current position of the square. So in the update function you need to tell the ball to move to the current position of the lowest square. (if that's the result you want I suppose) ?
  11. Zaidar

    Using Plugins

    Hi, I hesitated to create the same post couple of days ago. I was also sad that there isn't so much doc about plugins in Phaser. I was trying to use the Juicy plugin from the Phaser plugin repository. ( So i did like this : var GameState = { create: function(){ // rest of the code this.juicy = Phaser.Plugin.Juicy(this)); }, gameOver: function(bomb){ // when I need to call my plugin this.juicy.shake(); }}; PS: Pro tip : Don't forget to add the plugin script <script src="Juicy.js"></script> EDIT : Pro tip 2 : of course the use of this depend if you're using the OOP notation and game states and all that stuff. Try to play with the this value and console.log() Pro tip 3 : I'm not a pro
  12. I already had this issue. The way I do is I just multiply the physics calculation by the same scale factor. I know it's not the best way, but the only one I could think about. I have a scaleFactor variable, which depends on differents variables from the device, and just call multiply this variable when needed. I don't think it make too much loss of performance.
  13. I hope it's going to explain more in detail how to use the physics system, because for now I think it's still quite blurry in my head. Like : When should I declare game.physics.startSystem() ? I've used body and velocity without need for it. When should I declare a enableBody = true and physicsBodyType = Phaser.Physics.ARCADE, cause sometimes, it's working, sometimes, it's useless. Maybe it's just me but I found / still find this part of Phaser quite "difficult" to grasp in his whole. Thx anyway for the book.
  14. Hi, I think I got your problem, you need to enable the physics arcade system in order to use the velocity. Also, Game.physics.moveToObject, doesn't work, you need to explicitely say game.physics.arcade.moveToObject() Here is the code I have working : function create() { squares =; squares.createMultiple(20, 'square'); ball = game.add.sprite(365, 470, 'ball'); // ADDED PHYSICS HERE TO THE SPRITE game.physics.arcade.enable(ball, Phaser.Physics.ARCADE); timer =, add_squares); side = "right"; game.stage.backgroundColor = '#ffffff';} function update() {} function add_one_square(x, y) { var square = squares.getFirstDead(); square.reset(x, y); // ADDED PHYSICS HERE TO THE SPRITE game.physics.arcade.enable(square, Phaser.Physics.ARCADE); square.body.velocity.y = 300; square.outOfBoundsKill = true; // CHANGED TO PHYSICS.ARCADE game.physics.arcade.moveToObject(ball, square, 300); } Basically I saw that the console said velocity was a property of undefined. So the body didn't exist. That's why I thought the body was missing. I hope it fix your problem