Search the Community

Showing results for tags 'p2'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 333 results

  1. Why do p2 sprites in a group collide with each other when collideWorldBounds=true but when I set it to false they stop colliding?
  2. or phrased differently.. how do i get my polygons (created on an object layer in tiled) to appear in my phaser game world ? thx!
  3. Zef

    [WIP][Phaser] Moon

    Moon is a my first Phaser game... well if I'm entirely honest its pretty much the first proper game I have ever made other than a few experiments here and there. It is a take on the classic Lunar Lander. Its intended for mobiles primarily, and is by no means completely finished. I need to add sound, a loading bar, iron out a few bugs, and add a lot of polish to menus and instructions etc but it is coming along nicely. I am also considering implementing gyroscope controls if possible, but we will have to see how that goes It is pretty hard, I know, and I have actually been slowly decreasing the difficulty although I want to avoid making it too easy. I have used p2 for physics so it is a little performance heavy, but I have tested it on an iPhone 5, iPad mini, iPad 3rd gen, and HTC One all at 60fps so I am fairly pleased. On a very old and clogged up iPhone 4 it was still getting 30+ so not too bad. Anyway you can play it here: Moon I would love to hear what you think, and if you have any suggestion or discover a bug please let me know! Likewise if you have any questions about the game fire away
  4. Hi all, Trying to make a P2 body accelerate (as opposed to using moveLeft) but am having a tough time, tried to use applyForce like this: basket.body.data.applyForce([100,100], basket.x, basket.y);As well as this.. basket.body.data.applyForce([100,100], [basket.x, basket.y]);with no results. Anyone know what I'm doing wrong? I have tried changing the 100 to a number much larger as well as change gravityScale back to 1 (it is currently at 0). Thanks - Nick
  5. BigRob154

    P2 Increase body radius over time

    Hi I'm working on a prototype and have some problems with P2. I've some bubbles in the scene which grow over time. When changing the body's radius in the update function the whole scene gets out of control and the bubbles go crazy, jumping around everywhere. create: function() { this.game.physics.startSystem(Phaser.Physics.P2JS); for (var i = 0; i < 10; i++) { var x = (Math.random() * this.game.width) | 0, y = (Math.random() * this.game.height) | 0, d = 30; var s = this.game.add.sprite(x, y, ''); s.anchor.set(0.5, 0.5); this.game.physics.p2.enable(s); var p2Shape = s.body.addCircle(d, 0, 0, 0); s.body.debug = true; this.objects.push({ sprite: s, physicShape: p2Shape }); } }, update: function() { for (var i = 0; i < this.objects.length; i++) { var o = this.objects[i]; // same result //o.sprite.body.setCircle(o.physicShape.radius + 0.1, 0, 0, 0); o.physicShape.radius += 0.1; o.physicShape.boundingRadius = o.physicShape.radius; } }Am I doing something terribly wrong here?
  6. AlexArroyoDuque

    [2.0.3] checkIfCanJump always is false

    Hello, I upgraded from 2.0.2 to version 2.0.3. Everything works fine but the player does not jump. The checkIfCanJump function always returns false. There's something I have not updated correctly? A greeting.
  7. Raikoh

    P2 tilemap collision

    Im using tilemap with P2 and it says to set the tiles that you want to collide with (map.setCollisionBetween()) but even without this line all my tiles collide. I tried to set the collides parameter to false and the tiles still collides. In the P2 physique example "tilemap gravity" if i delete the line map.setCollisionBetween(1, 12) it doesn't change anything. ConvertTilemap is supposed to work only on the tiles that we define with map.setCollision, but it uses all the tiles on the layer. Is it a bug, or i don't get it?
  8. Hi all, new to Phaser here, loving the framework but finding the documentation kind of hard to navigate. Trying to find out how to make a 'basket' or 'bucket' object that can catch other spherical objects. I'm thinking it could be constructed of three rectangles even, the outer two at an angle. Is this possible with the Arcade Physics engine? If not, is there a better physics engine to choose? I'm not sure of the advantages and disadvantages of Ninja and P2 - does anyone have any insight that might be helpful? Thanks so much - Nick
  9. pandavigoureux29

    Trigger (with P2)

    Hi, this may be a stupid question, but I wasn't able to find anything on how to use a P2.Body as a trigger. Maybe it's my notion of "Trigger" that is wrong. I use this term because it's called like that in Unity. I mean here a body that sends a collision event but doesn't block anything. I know I could make a rectangle and check at each update if there's an object in it, but using the onBeginContact and onEndContact of P2.Body would seems more homogenous in my system. Thanks
  10. pandavigoureux29

    [P2] CollisionGroups and body.collides method

    Hi all, I have some issues with CollisionGroups ( I used to use them for ImpactEvents and am starting to wonder if there are not made just for that) I'll try to make it short and clear : Let's take two collision groups : var playerGroup = game.physics.p2.createCollisionGroup();var groundGroup = game.physics.p2.createCollisionGroup();Now let's take two sprites (assume they are created and physics is enabled) and set their collision groups: player.body.setCollisionGroup(playerGroup);ground.body.setCollisionGroup(groundGroup);With that if I want to enable collisions between these two sprites, I have to do this : player.body.collides(groundGroup);ground.body.collides(playerGroup);So here is the issue : if I put just one of these line, nothing happens. Isn't it enough to tell one body or the other to collide? It seems redundant to me. If that's the way it is, I'll deal with it, but I want to be sure I'm not making any mistake here Thanks
  11. Hello ! I have a quite big problem with physics.P2. I can't set sprite.x and sprite.y manually once the body is active. Actually, I have no errors, but it just isn't effective (the sprite ignore my manual positionning). I know I could do is with a sprite.reset(x,y); or with sprite.body.x and sprite.body.y but by those ways, it will reposition them from the center of the sprite and I don't want this. Thank you in advance for your anwers.
  12. My game is already quite complex and it's getting even worse ;-) because i have several objects that for example should collide with some other objects but not collide with a specific group of objects or because i'm using a postBroadphase callback and other things i think i need to work with collisionGroups, and therfore i need to set game.physics.p2.setImpactEvents(true);but rich said that those impactEvents are set to false because they are very expensive - so my question is the following: i have at least 8 kinds of GroupCallbacks with different collsionGroups that could be replaced with onBeginContact signals. while using object.body.collides([thisgoup,thatgroup]) for the overall collision handling would it make sense to use onBeginContact instead of groupCallback to get a better performance ?
  13. So I've been getting a problem with my P2 player sprite, where it triggers the collision callback two or three times, for a single collision. Basically, when to Flat Edges collide, its firing the collision callback twice You can replicate it by editing the "collision groups" master example First, modify the "hitPanda" method so we can see a hit count that increments with every collision callback: hitCount = 0;function hitPanda(body1, body2) { // body1 is the space ship (as it's the body that owns the callback) // body2 is the body it impacted with, in this case our panda // As body2 is a Phaser.Physics.P2.Body object, you access its own (the sprite) via the sprite property: body2.sprite.alpha -= 0.1; hitCount++ console.log("hitCount=" + hitCount);}Then modify the Ship's body to something non-circle, non-pointy, like 1 or 2 or 3 below: game.physics.p2.enable(ship, true); //true so we can see the physics body //ship.body.setCircle(28);1. ship.body.addPolygon(null, 0,0, 50,0, 50,50, 0,50); //simple square2. ship.body.setRectangleFromSprite();3. ship.body.setRectangle(50,50);Then, when you collide the ship into a panda, you very often get a double collision. The callback fires twice. Initially I thought it might be a problem with using a polygon body, as that's what I have in my current WIP. But setRectangle has the same problem. Then I thought it was the rotation, causing a tiny second hit as an objects start to rotate next to each other. And that would have explained why a circle worked ok in the example, because when it rotates it not going to hit anything twice. So I disabled all the rotation: panda.body.fixedRotation = true;ship.body.fixedRotation = true;But that didn't help. I think I've finally found the answer via the humble triangle. Here's a pic to better explain. - When I jab a panda with the right-side pointy end, I don't get the multiple hits. Just get a nice clean 1 hit. - Slap into a panda with the left-side flat edge. The Panda have rectangle bodies also. When the two flat edges hit together, bingo, two collision callbacks instead of one. Here's the triangle body code: ship.body.addPolygon(null, 0,0, 50,25, 0,50); //triangle with a point on the right side and flat edge on the left side.//btw, set pandas to show their body:panda.body.debug = true;So.... how to fix this issue? (I've attached my testing code with the .txt extension added to allow it to be attached to this post) collision groups.js.txt
  14. Hi, I was just wondering if there was anyway to use the moveToPointer function when using P2 physics or if there was anything similar to that. I'm trying to get bullets to move to the user's pointer. Thanks!
  15. here is the testcase: http://test.xapient.net/phaser/ALL/jumpthrough.html i made two versions of the checkOverlap() function.. in the second (commented out atm) i check in both ways but specially for the player velocity.. this leads to situations where the player velo is not enough anymore when "inside" the platform and bounces back really fast.. the first version somehow baffles me.. if the fist body is my player he always is moving UP.. therefore no further checks are needed.. i just let him through... BUT i honestly don't know the implications of that.. it's definitely not field tested the moving platforms would also work with a simple tween where i tween the velocity but with my custom function and some predefined attributes (bounds, velocity) that can also be configured in tiled so every platform already knows where to move, this is more precise.. @rich.. if this would be somehow suitable as an example feel free to copy/adapt/rewrite the code a small piece of the code: game.physics.p2.setPostBroadphaseCallback(checkOverlap1, this);function checkOverlap1(body1, body2) { if (body1.sprite.key === 'mario' && body2.sprite.key === 'platform'){ return false; } //for some reason if mario is body1 not body2 he is moving from below - thats all we need to find out to let him through return true;}function checkOverlap2(body1, body2) { if (body1.sprite.key === 'mario' && body1.velocity.y > 0 && body2.sprite.key === 'platform'|| body2.sprite.key === 'mario' && body2.velocity.y > 0 && body1.sprite.key === 'platform'){ return false; } // this checks if mario is jumping return true;}
  16. the funny thing is - it works in my demo game http://test.xapient.net/phaser/ALL/ but not in the much simpler testcase.. i'm unable to figure out what i need to do.. i tried applying materials, setting the circle different (i found out that friction is somehow dependant on the circle)...but nothing... here is the testcase: http://test.xapient.net/phaser/movingplatform.html here is the code: function preload(){ game.load.spritesheet('mario', 'assets/mariospritesheet-small.png',50,50); game.load.image('platform', 'assets/paddle-small.png'); }function create() { game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.gravity.y = 1200; game.physics.p2.friction= 5; platformH = game.add.sprite(300, 200, 'platform'); game.physics.p2.enable(platformH); platformH.body.kinematic=true; game.add.tween(platformH.body).to({ x: '+100' }, 2000,Phaser.Easing.Linear.None).to({x:'-100'}, 2000,Phaser.Easing.Linear.None).yoyo().loop().start(); player = game.add.sprite(150, 50, 'mario',1); game.physics.p2.enable(player); player.body.fixedRotation=true; cursors = game.input.keyboard.createCursorKeys(); jumpKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);}function update() { if (cursors.left.isDown ){ player.body.moveLeft(300);} else if (cursors.right.isDown ) { player.body.moveRight(300);} if (jumpKey.isDown ){player.body.moveUp(700);}}
  17. keyle

    Pinball like physics

    Hi. I'm attempting to make a pinball like game with Phaser. So far, not much luck with the physics system. I tried Arcade, Ninja and finally P2 and found the following issues: - Arcade and Ninja - I can't simulate the flipper hitting the ball at an angle. Seems the physic system is simplistic? I tried changing the angle and body angle with not much luck. - P2 - I can't seem to be able to "hold" the flipper at a fixed position, it always falls with gravitiy like the balls. Also, I can't seem to be able to change the anchor to something than the center of the sprite. Any help would be GREATLY appreciated.
  18. Hey guys, Was just wondering if anyone has worked out a way to constrain multiple sprites together using the Arcade engine in a similar way to the P2 method? I'm mainly looking for an equivalent of the lock constraint but I guess any of them would be useful - right now i'm setting the x/y position in the update function and it's got a visible lag - any ideas?
  19. powerups = game.add.group(); powerups.enableBody = true; powerups.physicsBodyType=Phaser.Physics.P2JS; map.createFromObjects('objects1', 339, 'questionmark', 2, true, false, powerups);powerups.forEach(CallsignIt,this);so the physics bodyis created.. i can apply a rectangle, a body.mass, static, name... but then the "setCollisionGroup" option failes. Uncaught TypeError: Cannot read property 'mask' of undefined function CallsignIt(callsign){ callsign.body.setRectangle(64,64); callsign.body.mass=99; callsign.body.static = true; callsign.body.sprite.name="growshroom"; callsign.body.setCollisionGroup(questionmarkCG); callsign.body.collides([playerCG,fireballCG]);}i also tried it that way: (but then nothing happens) powerups.callAll('setCollisionGroup', 'null', 'questionmarkCG');what am i doing wrong? thx
  20. AlexArroyoDuque

    P2 bad performance?

    Hello! Since I've migrated to Phaser 2.0.0, the game has a very poor performance. I use the system P2. Is it normal?
  21. Hey guys! I'm just starting out with Phaser game programming. I'm trying to build a proof of concept rope system. I for some reason, when I apply gravity, the revolute joint fails. Not sure what to do. Any ideas? Also, I'm running off the dev branch. You can find my demo here: https://dl.dropboxusercontent.com/u/21728452/Games/phaser-master_V2/rope/index.html Thanks! preload: function() { game.load.image('rope_piece', 'assets/rope_piece.png'); }, create: function() { cursors = game.input.keyboard.createCursorKeys(); game.physics.startSystem(Phaser.Physics.P2JS); rope_1 = game.add.sprite(100,100,'rope_piece'); rope_2 = game.add.sprite(100,110,'rope_piece'); game.physics.p2.enable([rope_1]); game.physics.p2.enable([rope_2]); //game.physics.p2.enable([rope_3]); game.physics.p2.gravity.y = 100; //rope_1.body.clearCollision(true, true); //rope_2.body.clearCollision(true, true); //rope_1.body.mass = 0; rope_1.body.data.motionState = 2; //rope_2.body.data.motionState = 1; constraint = game.physics.p2.createRevoluteConstraint(rope_1, [0,-5], rope_2, [0,5]); }, update: function() { if (cursors.up.isDown) { rope_2.body.thrust(50); } else if (cursors.right.isDown) { rope_2.body.rotateRight(5); } //rope_1.body.setZeroVelocity(); },
  22. ...when one of those buttons is the keyboard cursor RIGHT. here is an example to test it: http://test.xapient.net/phaser/nojumprightandfire.html try to hold down M and SPACEBAR and then move to the right RIGHTCURSOR.. it simply does not work BUT try moving to the left.. it works !! ?? i've testet it in 1.1.5 and in 2.0 - the same problem it comes down to the simple statement that you can not use cursors.right with more than 1 other button together...
  23. AlexArroyoDuque

    It can be used emitters with P2 physics?

    Hi game developers! The player of my game uses P2 physics. I need that when an enemy dies and drop coins the player can catch them. Therefore, the player must be able to collide with the coins.
  24. http://test.xapient.net/phaser/ALL/ jump right into the first whole (and die) 5 times and suddenly you will fall through the tielmap... no idea what causes it... i will try to setup an easier test environment for this with less code and report here if i find something
  25. AlexArroyoDuque

    p2 physics overlap?

    In version 1.1.6 it was possible to use overlap in collisions. There is something similar in the physics system p2? Now I use to define collision the "collides" function: collides (group, callback, callbackContext, shape) The problem is that the player can walk over enemies for example.