Jump to content

gauravD

Members
  • Content Count

    27
  • Joined

  • Last visited

Everything posted by gauravD

  1. Okay. Fixed. http://jsfiddle.net/gauravdixitv/6acmp7h5/ Turns out Phaser uses physics.p2.pxmi (pxm inverse) to anchor a prismatic joint - https://github.com/photonstorm/phaser-ce/blob/master/src/physics/p2/PrismaticConstraint.js#L39 BUT, physics.p2.pxm to anchor a linear spring - https://github.com/photonstorm/phaser-ce/blob/master/src/physics/p2/Spring.js#L59 What is up with this ?
  2. You need to add the same angle constraints to bullet firing too. So instead of firing when the pointer is down, if (game.input.activePointer.isDown){ fire(); } you fire when the pointer is down and your sprite follows your angle constraints. if (game.input.activePointer.isDown && sprite.angle >= -90 && sprite.angle <=90){ fire(); }
  3. You are right - works flawlessly in p2.js - http://www.physicstoy.com/383# Seems like the Phaser P2 plugin then. Will investigate some more today and get back to you!
  4. Like @casey said, animations (tweens) and timers will help you. An example - https://jsfiddle.net/gauravdixitv/L422hqk9/
  5. Hi Casey. Children of a group will be rendered in the order in which they are added (unless of course you change the order with functions like sendToBack()). Because you add the background first, it will be rendered before everything else (so you don't need the call to sendToBack() on bg), and the text should appear on top - https://jsfiddle.net/gauravdixitv/r6v7sLkw/ Perhaps, you are changing the group's order somewhere else in your code?
  6. Oh right! I stand corrected
  7. Cool Your fiddle was using an older version. You can always check what version you are using - Phaser prints it in your console! Um, depends on how you are including it. It might look like <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.2/phaser.min.js"></script> //Or If you have downloaded the source, it could be something like: <script type="text/javascript" src="../libs/phaser/phaser.min.js"></script> You can update to phaser-ce by 1. Grabbing the latest source from https://github.com/photo
  8. It does render quads. But it uploads the entire buffer every frame - come to think of it, this will usually be necessary if all/most objects in the scene move. I was working on a game where a few hundred quads would remain static throughout and other objects (quads) moved. Uploading just the bufferSubData() helped me with performance significantly! Also, are you using multi texture batching? You might also want to try Phaser 2.6.2; Apparently, it performs much better than the current ce version. PS Could you please check the number of draw calls you get with webGL?
  9. Hi. Prismatic and Spring joints in p2js seem pretty straightforward. I was wondering why using constant rest length, stiffness and damping for a spring would change its behavior when a body's local anchor is changed. Fiddle: http://jsfiddle.net/gauravdixitv/83bkhr3f/ (phaser/p2js template from inkfood) From the fiddle, all the springs use share the same parameters except the local anchor of body A. Why do the springs behave differently? :/
  10. Hey. Poor webGL performance could be due to a few things aside from phaser.debug. Because your scene is large, it might be due to Phaser(pixi) uploading entire buffers on the GPU every render frame. Perhaps, some profiling could help you? Check out #356!
  11. Hi Tom. Camera follow has been fixed in a newer version of Phaser. You should update to either phaser-ce or 2.6.2 Because you move the camera around, the pointer's arctan to the player will not be computed correctly if you use the pointer's local (x,y). You need the arctan from the pointer's (x,y) in world coordinates. Passing the world to moveToPointer(), will use the pointer's world coordinates (this is not intuitive, I know). game.physics.arcade.angleToPointer(player, game.input.activePointer, game.world); With these changes in, check out : https://jsfiddle.net/gauravdixitv
  12. Hi wexing. What do you mean by overflow? The ball slightly entering the right_hoop ? This might be due to tunnelling. AFAIK, p2js only partially supports Continuous Collision Detection, if at all. Making the hoop rects slightly wider, will help - https://jsfiddle.net/gauravdixitv/cb0z6yb7/
  13. Hey Teonnyn. You get this behavior because the point (X, Y) is on the physics world boundary. If your body is set to collide with world boundaries (which it is by default), and you create it on the boundary, the collision will force the body out with an impulse. https://jsfiddle.net/gauravdixitv/q3yjsk9e/ set the variable center to false, and you will see the ball behaving like it does in your code. If you want your ball to come in from outside, make the world bigger
  14. Looking good Costin! Aside from the webpack boilerplate, the prefab and helper templates will be helpful for new phaser+typescript developers
  15. Perhaps, you are looking for this.game.add.existing(). Try, this.game.add.existing(this.character);
  16. You can reset all your variables in the state's shutdown() and then call game.state.restart() (saves you the trip to Gameover too :)).
  17. You are using Typescript; Why not make use of the awesome things it adds to JS? Take a look at https://github.com/gaurav-dixitv/PhaserPostProcessing/tree/master/src for a complete project template that uses Typescript and Phaser. You could create a state (boot.ts) like so: export class Boot extends Phaser.State { public preload(): void { } /** * Use this to set global properties such as resolution, aspect ratio, et cetera. * * * @memberOf Boot */ public create(): vo
  18. Turning off antialiasing should get rid of those lines for now. Of course, this should not be the solution - I will take a look and report back if I find anything.
  19. The text objects accept input because they are added as the button's children: https://jsfiddle.net/2fet6pLf/ In your case, the hierarchy also seems a bit incorrect logically. The texts and the button should have a common parent (perhaps, call it a TextButton ). //TextButton pseudocode TextButton : Sprite { titleText: Phaser.Text //TOP_CENTER descText: Phaser.Text //CENTER button: Phaser.Button //BOTTOM_CENTER TextButton(){ this.addChild(titleText); this.addChild(button); this.addChild(descText); } }
  20. @samme's answer should work just fine. Regardless, since jump1() and jump2() are equivalent, why not just use jump()?
  21. Ha! https://gaurav-dixitv.github.io/phaser/2017/07/27/texture-repeat.html There you go. This shows you how to do exactly that (except you can ignore the texture code if you want to).
  22. Try this.game.physics.p2.removeBodyNextStep( equation[0].bodyA ); and this.game.physics.p2.removeBodyNextStep( equation[0].bodyB );
  23. Shameless plug: https://gaurav-dixitv.github.io/phaser/2017/06/08/phaser-shaders.html should help you use your own quads. But I am guessing this would be an overkill. What do you want to achieve?
  24. Vertices of a p2 polygon are relative to the center of the polygon. Supposed you wanted a 2x2 square, the vertices would be [ [-1, -1], [1, -1], [1, 1], [-1, 1] ] (CCW direction). When your sprite is at [100, 100], the first vertex would be at 100 + game.p2.mpx(-1) = 80. Where, game.p2.mpx() converts meters(p2 units) to px(Phaser units). If you scale the sprite, you need to take that into account as well. If you rotate a sprite and the p2 vertices stay the same, you can calculate them like so: function myFunction(){ //get rotated vertex[0] in screen coordinates. let p2
×
×
  • Create New...