Zaidar

Members
  • Content count

    121
  • Joined

  • Last visited

About Zaidar

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  • Location
    Lyon
  1. Thank you very much !
  2. 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.
  3. Draw an Arc

    create: function(){ this.circle = this.add.bitmapData(resolutionGame[0], resolutionGame[1]); this.circleSprite = this.add.sprite(0, 0, this.circle); }, update: function(){ this.circle.ctx.beginPath(); this.circle.ctx.arc(x, y, radius, angleStart, angle); this.circle.ctx.strokeStyle = '#000000'; this.circle.ctx.stroke(); this.circle.ctx.closePath(); },Something like this should work. I haven't done game dev for few of weeks, so can't remember
  4. The first official Phaser book

    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)
  5. CocoonJS Canvas+ Rendering

    You need to put a background, otherwise Cocoonjs just try to fill with the sprite.
  6. 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?
  7. 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) http://jeandaviddaviet.fr/games/Bombomb/ This is the source on Github : https://github.com/JeanDavidDaviet/Bomb-omb/blob/master/script.js 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.
  8. 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);
  9. Little Problem in example.phaser.io

    I don't really understand the problem, but the site is planned to be redesigned soon, so...
  10. Water, liquid, fluids

    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 http://gamedevelopment.tutsplus.com/tutorials/creating-dynamic-2d-water-effects-in-unity--gamedev-14143 If you have any new thing on this don't hesitate to keep us to date.
  11. Game Mechanic Question

    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 = game.add.group();// 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 = this.game.time.events.loop(1000, 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) ?
  12. 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. (https://github.com/photonstorm/phaser-plugins/tree/master/Juicy) So i did like this : var GameState = { create: function(){ // rest of the code this.juicy = this.game.plugins.add(new 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
  13. Camera Scale and physic problem

    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.
  14. The first official Phaser book

    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.
  15. Game Mechanic Question

    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 = game.add.group(); 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 = this.game.time.events.loop(500, 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