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. My first game using Phaser. It was created as an interactive new years greeting card. And while there's still winter in europe, i thought its nice to let the game into the public. link: http://12brols.com/3brols/sledge-game/EN/ Ride the sledges and collect bonus points. Avoid knocking down the trees and snowmansand have a good 2015. Game is based on P2 physics engine. It can be played on mobile devices as well with some controls (jumping) and collisions (for trees and snowmans) disabled. The frame rate on mobile varies somewhat betweet 25 and 50 FPS. Controls: up - accelerate down - brake left - rotate left right - rotate right I hope you will enjoy it!
  2. Hi, I have this character that I need to play a walking animation for while on-ground, but a jumping animation when not. I am using "body.onBeginContact()" & "body.onEndContact()" to set a variable "onground" = true/false to choose which animation should play. Since my terrain consist of a bunch of polygon, making for a somewhat edgy ground, my character will needless to say sometime bounce a little bit off the ground, calling these two events very quickly in succession. This happens quite a lot, meaning the player very quickly, just while running along the ground, switches between the two animation modes, which is my first problem. In addition to this problem, there seems to be times when "body.onEndContact()" is called but "body.onBeginContact()" is not called afterwards, so even though the character is standing on the ground he is not considered to be colliding, so I think I need some other function to check for collision as this is erroneous. I am asking anyone here if they have had the same problem and found a good solution. A good solution would in my books be something that can tell if two bodies are touching or have touched within the last few frames or x milliseconds.
  3. I have a car similar to this demo...it uses P2 physics, CollisionGroup, springs and constraints to simulate the car body and two wheels. http://www.inkfood.com/create-a-car-with-phaser/ Question is how can I make the car "explode" or fall apart when needed? e.g. Collision with object or velocity is too fast, etc. I've tried to remove the springs or constraints but the car flies off the screen unpredictably. Optimally I would like to remove the spring/constraints and just have the 3 car pieces just tumble on the ground disconnected, or I could add random forces to the pieces to simulate a small explosion.
  4. how to achieve something like this: http://examples.phaser.io/_site/view_full.html?d=arcade%20physics&f=bounce.js&t=bounce with P2?
  5. flowabuse

    Physics for arc graphics object!

    How can I add physics to a object like this :http://jsfiddle.net/f6tf8ue9/17/ ? I am trying to make a breakout game and i want to use an arc that moves and scales in a circular manner ( exactly like the progress bar in the link) , that would be my paddle that would not allow a ball to reach the center. Can this even be done?
  6. Hello, i have this problem i want to call a function when two body of the same group collide. Here is my try: pedone.body.setCollisionGroup(pedoneCollisionGroup); pedone.body.collides([pedoneCollisionGroup, playerCollisionGroup]); pedone.body.createBodyCallback(pedoneCollisionGroup, pedonehitpedone, this);the function pedonehitpedone is not triggered any suggestion? sorry i'm pretty new to phaser and coding...
  7. As the title states, whenever I debug my p2 bodies using the suggested "body.debug = true" method, they show up with the correct size, but are rendered at coordinates 0, 0. I can confirm that the actual physics body is at the correct position, only the debug graphics is at the wrong place. I am using Phaser version 2.2.1, the bodies are static and have "sensor" set to true. If you need more information, please ask. EDIT: I have managed to make an ugly fix for this using: if(developerSettings.debug) { this.body.debug = true; this.body.debugBody.x = this.body.x; this.body.debugBody.y = this.body.y; }This is of cause not pretty, will only render the initial position of the body, and should be unnecessary. It seems like the debugBody position is not being set correctly in the core.
  8. skywalker

    p2 collision is lost !

    i created 2 sprites and added p2 body for each of them first on is the player it is , second is static and when i checkd for collision for each of them it works but only if the second one is not moving when i move the second sprite around the world for example this.update = function(){ block.body.x = block.body.x -1; }; it is not collide with the other sprite what is the problem :/ !
  9. DisabledGamer7

    p2 collide between group

    Hi all!, I'm a newbie in coding game and starting from example and a lot of google i came up with my first test. You can see a live preview here http://montericco-beb.it/test/gioco/macchina.html using my parent site to test... The problem i'm having is that i wish the zombies to have a little of drag and also that when they hit each other, with a certain velocity they will play the dead animation. Also adding mobile and mouse control... Here is the code: var w = window.innerWidth * window.devicePixelRatio, h = window.innerHeight * window.devicePixelRatio;var game = new Phaser.Game((h > w) ? h : w, (h > w) ? w : h, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });function preload() { game.load.spritesheet('car', 'assets/car.png', 76, 47); game.load.image('ice', 'assets/ice.jpg'); game.load.spritesheet('pedone', 'assets/pedone.png', 32, 48);}var car;var cursors;var score = 0;var scoreText;var land;function create() { game.physics.startSystem(Phaser.Physics.P2JS); land = game.add.tileSprite(0, 0, (h > w) ? h : w, (h > w) ? w : h, 'ice'); game.physics.p2.setImpactEvents(true); game.physics.p2.restitution = 0.7; scoreText = game.add.text(16, 16, 'score: 0', { fontSize: '32px', fill: '#000' }); var playerCollisionGroup = game.physics.p2.createCollisionGroup(); var pedoneCollisionGroup = game.physics.p2.createCollisionGroup(); game.physics.p2.updateBoundsCollisionGroup(); var pedones = game.add.group(); pedones.enableBody = true; pedones.physicsBodyType = Phaser.Physics.P2JS; for (var i = 0; i < 70; i++) { var pedone = pedones.create(game.world.randomX, game.world.randomY, 'pedone'); pedone.body.setRectangle(32, 48); pedone.body.setCollisionGroup(pedoneCollisionGroup); pedone.body.collides([pedoneCollisionGroup, playerCollisionGroup]); pedone.body.collides(pedoneCollisionGroup, pedonehitpedone, this); // this is my tentative but not work pedone.body.angle = game.rnd.integerInRange(-180, 180); var angleped = pedone.body.rotation + (Math.PI/2); pedone.body.velocity.x = -30 * Math.cos(angleped); pedone.body.velocity.y = -30 * Math.sin(angleped); pedone.body.mass = 0.3; //test for drag pedone.body.linearDamping = 1; //test for drag pedone.angularDamping = 1; //test for drag pedone.damping = 1; //test for drag pedone.inertia = 0.2; //test for drag all no effect } pedones.callAll('animations.add', 'animations', 'walk', [0, 1, 2, 3, 4, 5, 6, 7]); pedones.callAll('play', null, 'walk', 7, true); car = game.add.sprite(200, 200, 'car'); game.physics.p2.enable(car, false); car.body.setRectangle(76, 47); car.body.allowRotation = true; car.body.immovable = true; car.body.mass = 1; car.body.setCollisionGroup(playerCollisionGroup); car.body.collides(pedoneCollisionGroup, hitpedone, this); cursors = game.input.keyboard.createCursorKeys(); this.input.onDown.add(click, this); //mouse and touch control test not working this.input.onUp.add(release, this); //mouse and touch control test not working this.input.addMoveCallback(move, this); //mouse and touch control test not working}function click() { var angleclick = car.body.rotation + (Math.PI); car.body.velocity.x = -500 * Math.cos(angleclick); car.body.velocity.y = -500 * Math.sin(angleclick);}function release() {}function move() {}function hitpedone(body1, body2) { body2.sprite.animations.add('dead', [7, 8, 9, 10]); body2.sprite.animations.play('dead', 12, false,true); body1.sprite.animations.add('schizzo', [1, 2, 3]); body1.sprite.animations.play('schizzo', 1, false); score += 10; scoreText.text = 'Score: ' + score;}function pedonehitpedone(body1, body2) { body2.sprite.animations.add('dead', [7, 8, 9, 10]); body2.sprite.animations.play('dead', 12, false,true); score += 10; scoreText.text = 'Score: ' + score;}function update() { car.body.setZeroRotation(); car.body.setZeroVelocity(); var angle = car.body.rotation + (Math.PI); if (cursors.left.isDown) { car.body.angularVelocity = -7; } else if (cursors.right.isDown) { car.body.angularVelocity = 7; } if (cursors.up.isDown) { car.body.velocity.x = -500 * Math.cos(angle); car.body.velocity.y = -500 * Math.sin(angle); } if (cursors.down.isDown) { car.body.velocity.x = 500 * Math.cos(angle); car.body.velocity.y = 500 * Math.sin(angle); }}function render() {}Thank you very much if you will help! Have a nice day !
  10. im a beginner in Phaser.js game development and i want to create static body to group , with p2 physic system i created the group and then started the physic system. var block_group = game.add.group(); var Y = 20; for (var i = 0; i < numberOfBlocks; i++) { block_group.create(400,Y,'block'); Y = Y +15; }; game.physics.startSystem(Phaser.Physics.P2JS); block_group.enableBody = true; block_group.physicsBodyType = Phaser.Physics.P2JS; when i print block_group.body it gives me undefined so i tried using forEachAlive and it stile the same however it works fine for single sprite , but with a group it is not working .
  11. Hey there, I was wondering whether there was an easier of dealing with curvy shapes such as the one I have attached. I've done a similar shape that was much smaller using P2 physics and handing in to physics a JSON of smaller rectangles to handle collisions. This took me quite a while though especially to get something that acted smoothly. Is there any way of adding either physics data or drawing this shape with P2 so that it can collide well with other objects? Thanks in advance!
  12. I'm developing a game which makes use of the P2 physics system. I have a group of sprites with static P2 bodies which must collide with another sprite with a dynamic body. This all works dandy until I call the .kill() method on one of the static bodies and then respawn it somewhere else via .reset(x,y). After reseting it, it no longer collides with the dynamic body? After hours of debugging I've figured out that if I make the bodies static then collisions still work after a kill/reset. This doesn't help me that much however as I need them to be static. I've made a jsfiddle to illustrate the problem: http://jsfiddle.net/xdb9s6d1/5/ (NOTE: click the big boxes to kill/reset them) Cheers!
  13. sinanqd10

    How can I make a jump on P2?

    Can anyone guide me the way to do a jump on P2? I have read this article about the jump on P2 http://www.html5gamedevs.com/topic/6148-the-moving-jumpthrough-platform-sum-up-thread-help-very-much-appreciated/, but what I actually wanted is that: I want to jump depend on how I press the key : example: if I press slightly, it will jump a little and if I press hardly, it will jump high. please give me a demo. Thanks you for helping.
  14. I'm trying to figure out how to best detect overlap between a tileSprite that's resizing and relocating every frame (I use it to visualize a physics spring) and a group of sprites with circular P2 bodies attached (in order to remove the spring upon contact). I tried attaching a P2 body to the tileSprite (spring) and call body.setRectangleFromSprite() every frame like so: spring.body.x = x;spring.body.y = y;spring.width = width;spring.body.angle = angle;spring.body.setRectangleFromSprite();...and was planning to enable the body's data.shapes[0].sensor for overlap detection as described here: http://www.html5gamedevs.com/topic/5567-trigger-with-p2/ However, for some reason the body's angle is different from the sprite's angle (see attached images) (I'm ignoring the body's offset for now). The body appears close to perpendicular to the sprite when the sprite is almost vertical, while the body almost matches the angle when the sprite is close to horizontal. Math has always been my Achilles' heel, but this smells like a sine/cosine problem to me. Am I doing something wrong? Or is there an altogether better way of going about this? Many thanks in advance to this wonderful community!
  15. Hi all, In my game I have circles which are spawned and then are tweened over time to adjust their scale. This is working however, I want to detect when two circles collide and run a function when this happens. All the circles are in a group. I have tried using arcade physics however after researching I found out that collision detection only works if the sprites have motion, and mine do not they are just being tweened, arcade physics also doesn't have a circular hit box. I then decided to look into P2 physics which does work and the collisions are detected, however, it causes the circles to move off screen, this can be solved by making each circle static but then collisions are not detected between them. Also, without the circles being static although the collisions are detected they are detected when the circles are not even touching. Thanks for your help.
  16. Hey Everyone, I just completed and released a simple, physics based game that user Phaser. As the circle, your job is to avoid the triangles and gain points by hitting the rectangles. The game gets progressively harder after certain point thresholds are reached. The level change is indicated by the player (circle) changing colors. The game is intended to be challenging, however there is strategy in controlling the player which will allows for much higher scores. Leaderboard and achievements have been included on each platform using Google Play Games and iOS Game Center. https://play.google.com/store/apps/details?id=com.soquilistudios.shapeitoff&hl=en https://itunes.apple.com/us/app/shape-it-off/id951345869?mt=8 The iOS version has a new version with bug fixes waiting for review (current version still playable), but the Android version is up-to-date. Feedback is welcome. Thanks
  17. DeViLaToR

    p2js just for collision detection

    Hello everyone! I am making a game and i have some objects with triangular shape. I use p2js just for collision detection with onBeginContact (everything else is handled manually, like movement etc.). So i am wondering if there is a less expensive way to detect polygon collision. Thanks
  18. schmevie15

    Rolling a circle down a hill?

    So currently I am making a 2D game with Phaser P2 Physics that involves a ball rolling along, sort of like a platformer, I am trying to make it both difficult for the ball to roll up a hill and then easy for it to roll down. I know increasing the gravity will do the trick, but then the global gravity will be increased and the ball will basically be sucked to the ground. I've performed some tests and I had to change the gravity to about 10000 to get it to roll down at a noticeable speed. Now is there an easier/better way to do this using some of the Phaser P2 Physics attributes? I appreciate any and all help! Thanks!
  19. i opened this thread because the title of the thread where i found this problem is misleading.. so sorry for the double post as you can see in the attached image the physics body of a fast moving sprite is sometimes far from directly below the sprite. this is usually not a problem but when i try to make another spirte follow the first sprite it will always follow the physicsbody which is at a different position this looks weird and renders the whole thing unusable.. in my case this should be a visual aid but if its pointing towards the wrong x and y coordinates it makes no sense
  20. schmevie15

    Rotating a circle along a path

    Hey all, I am currently trying to rotate a ball along the ground using the rotateLeft and rotateRight methods included in P2 physics. Currently the behavior is that the ball rotates but it doesn't seem to move upon rotating but rather it gets a couple of revolutions in and then glides across and then even when the ball has stopped rotating it continues to slide across. I'm guessing this has to do with there not being any friction, is there any way to get friction on the world balls or is it better to just add a material and have the ball rotate along it? Any help is greatly appreciated thanks! Example here:https://dl.dropboxusercontent.com/u/15582110/meteroar%21/Meteroar.html
  21. Hi, I loaded my tiles with game.physics.p2.convertTilemap() and it works. However, each tile is a square block and my "player" is floating on slanted tiles (similer to problem mentioned in here). Using Tiled editor's "Tile Collision Editor", i defined the polygon I want but Phaser does not seem to pick it up. Part of the exported JSON looks like this (tells me that the polyline was created): "tilesets":[ { "firstgid":1, "image":"tiles.png", "imageheight":374, "imagewidth":374, "margin":0, "name":"tiles", "properties": { }, "spacing":2, "tileheight":32, "tiles": { "57": { "objectgroup": { "draworder":"index", "height":0, "name":"", "objects":[ { "height":0, "name":"", "polyline":[ { "x":0, "y":0 }, { "x":32, "y":-32 }], "properties": { }, "rotation":0, "type":"", "visible":true, "width":0, "x":0, "y":32 }], "opacity":1, "type":"objectgroup", "visible":true, "width":0, "x":0, "y":0 } } }, "tilewidth":32 }, { "firstgid":122, "image":"items.png", "imageheight":270, "imagewidth":270, "margin":0, "name":"items", "properties": { }, "spacing":2, "tileheight":32, "tilewidth":32 }, { "firstgid":186, "image":"sprites.png", "imageheight":100, "imagewidth":238, "margin":0, "name":"sprites", "properties": { }, "spacing":2, "tileheight":32, "tilewidth":32 }]How do I load the tile's collision polyline/polygon in Phaser when loading the tiled layer?
  22. I'm trying to implement a platformer using p2 physics. There's known issue with tiles converted to collide boxes with p2.convertTilemap(). I can propose an example of how it affects gameplay: http://codepen.io/anon/pen/lJGqB. It turns out that length of narrowphase.contactEquation list sometimes is 0 even when the player crashes into the tiled wall. The issue is being discussed from time to time (e.g. http://www.html5gamedevs.com/topic/8895-p2-when-the-player-touches-a-wal-over-the-side-it-gets-stuck/) but seems to have no other solution but "use polylines instead of tiles". The trouble is that my tilemaps already have lots of collide tiles. So I wonder if there is a way to modify checkIfCanJump() function (the function is taken from http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=tilemap+gravity.js&t=tilemap%20gravity and in my example is modified as playerTouching() according to http://www.html5gamedevs.com/topic/6502-bodytouchingdown/). Maybe I should tinker deeper with threshold = 0.5 or use different collide equation list than p2.world.narrowphase.contactEquations.
  23. I'm creating 2 circles using graphics and adding them to sprites. I'm trying to make the sprites contact each other, but the function added on onBeginContact is called before the objects touch. I have a jsfiddle here: http://jsfiddle.net/vL6gkeue/ Can anyone please let me know why there is space between the two bodies yet they appear to have made contact?
  24. seejay92

    P2 Contact Material Question

    Hi everyone, Just a quick question for those with experience using P2. I'm creating a simple 2D sidescrolling golf game (using Typescript) and I've set up a polygon array creating random terrain Y points and a ball with P2 physics. The collisions between both using the contact material work perfectly, including Restitution and Surface Velocity but I was wondering if there was anyway to create drag when the ball rolls over the terrain. Just now, if there is even a slight hint of angle to a hill the ball will continue to roll down it due to gravity without any drag to slow it, or even if its flat it will continue at a steady pace. I've tried changing the contact material's friction to extremely high but this doesn't seem to have much affect slowing the velocity. Here's the settings for my contact material: this.contactMaterial.friction = 1e7; this.contactMaterial.restitution = 0.4; this.contactMaterial.surfaceVelocity = 0; // contactMaterial.stiffness = 1e7; // contactMaterial.relaxation = 3; // contactMaterial.frictionStiffness = 1e7; // this.contactMaterial.frictionRelaxation = 0.1; The temporary fix would be to call an event for when the two materials are touching which slows the ball's velocity to closer to 0, but I'm sure theres something easier I'm just missing as this is my first time using P2. Also as a little extra, could someone explain what the commented out properties of the material do? I know roughly what stiffness and relaxation do with Springs but I'm not too sure what affect they have in contact materials - they are probably the properties I need properly set to achieve my drag! Thanks as ever guys! SeeJay
  25. there are several occations where my player gets faster and faster all the time without limit.. (this is on purpose but it shouldn't end up in lightspeed.. a velocity of 800-1000 would be more than enough) how would i define such a limit and make sure it's applied? thx in advance