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
    • 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 332 results

  1. ewpolly1

    Hittest a tilesprite?

    I have recently attempted to switch several parts of my game from sprites with static p2 bodies attached, to tile sprites with static p2 bodies for texture purposes. However, the tile sprites do not seem to be detected at all with p2 hittest. I have done some research, but the most that I have found is that tile sprites has their own hitarea property, however there is little to no explanation for how to use this. As an additional point, some of the tile sprites are rotated, if that is at all relevant. Is there a simple way to recreate the hittest of a standard sprite on tile sprites(i.e. Adjust the hitarea to cover the sprite)? Any help is appreciated.
  2. Kyle Berezin

    Less than infinite mouse force with p2

    I am making a quick demo that is built of off the p2 ragdoll demo. I am not running Phaser, just standalone p2 with p2 renderer. I have a linkage that is anchored to a fixed point that can be articulated with the mouse. The issue is that the mouse can easily... dislocate the linkage due to the mouse having infinite force. I came across an example for Phaser called mouse spring but I was unable to adapt it to standalone p2 with p2rederer. I attempted to hijack the mouse down functions but I'm not really familiar with p2, this was meant to be a slapped together demo. Any help would be greatly appreciated, I have attached what I have so far. ragdoll.html
  3. Hi, dear game developers. I had seen that link on examples load-polygon-1 or var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.image('contra2', 'assets/pics/contra2.png'); // Load our physics data exported from PhysicsEditor game.load.physics('physicsData', 'assets/physics/sprites.json'); } var contra; var start = false; function create() { // Enable p2 physics game.physics.startSystem(Phaser.Physics.P2JS); contra = game.add.sprite(400, 300, 'contra2'); // Enable the physics body on this sprite and turn on the visual debugger game.physics.p2.enable(contra, false); // Clear the shapes and load the 'contra2' polygon from the physicsData JSON file in the cache contra.body.clearShapes(); contra.body.loadPolygon('physicsData', 'contra2'); // Just starts it rotating game.input.onDown.add(function() { start = true; }, this); } function update() { if (start) { contra.body.rotateLeft(250); } } function render() { } , and i'm trying create json like that, since i saw that example. I saw some suggestions about physics editor or mapeditor tiled. i installed it, but i have no idea about creating json like that despite researching how its doing on internet. Probably i need some help
  4. Hi Guys, I've come across a problem with p2 body. I have 2 sprite, sprite1 is physics enabled, and sprite2 is create a Phaser.Physics.P2.Body They will be moving using velocity after 2 seconds, but sprite2 not working... I made a JsFiddle to explain my question. https://jsfiddle.net/pbq93enn/ Does anyone have an idea what I'm doing wrong? Thanks in advance!
  5. So I have been searching a solution for this for 2 days now. I have a character with physics body. This character has sprites attached to it with addChild(). Arms, sword, cloak, range indicator. Range indicator also has a body (only used as sensor/trigger ). However as I found out addChild doesn't work on physics bodies. Sprites move together but I can get Range Indicator's body to move with them. It pretty much sits in the corner. Since addChild() is no go for physics bodies, is there anything else I can use with this? Really trying to avoid writing a custom function to make the body follow me but running out of options here. EDIT: Found a workaround for weird child behaviour with bodies. Added another invisible sprite and made it child to my body. this.rangePositioner = game.add.sprite(0, 0, 'rangeBlack'); this.rangePositioner.anchor.set(0.5); this.rangePositioner.pivot.set(0, 40); this.addChild(this.rangePositioner); Take its world position with rangePositioner.world ( rangePositioner.position returns 0 ) then set it to my child body.position. I had to dig for some time before I realized sprite.world returns a point. I would expect it to be named something like worldPoint. Anyways I hope this helps someone.
  6. przemoo83

    Collision with tilemap in P2

    How do I add a terrain that is built from tilemap to a collision group? I couldn't find any examples
  7. I have a sprite sheet of my games playable character. The frames consist of all possible actions the character can do, including two different attacks. I want to change the physics bounds on different animations as my sprites positioning obviously changes with different animations. I got PhysicsEditor expecting it could handle this but as far as I can see, it only works for single images. Is there any solutions for this to help me get near pixel perfect collision? Any help is appreciated as always
  8. Hey, I'm using p2 physics and I have a sprite (pixel line) that is rotating around some point (beginning of the line). For rotation I use angularVelocity. To display my sprite correctly I had to set it's anchor to (0,1) and it works fine, but collision box remained where it was before. Please check out my code and attached image game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.setImpactEvents(true); this.obstacle1CollisionGroup = this.game.physics.p2.createCollisionGroup(); this.obstacle = game.add.sprite(700, 400, "line"); this.physics.p2.enable(this.obstacle, true); this.obstacle.body.setCollisionGroup(this.obstacle1CollisionGroup); this.obstacle.anchor.setTo(0,1) this.obstacle.body.angularVelocity = 0.3; this.obstacle.body.angularDamping = 0;
  9. Runnable code here: https://github.com/darkf/grr I'm using P2 physics and I'm trying to raycast to the mouse position. I've got a tilemap with physics bodies set up, and they show fine with debug draw on. However, the ray never hits any of the tile bodies, nor the player body. It only hits the top and left side of the world bounds. Screenshots attached. Is there anything obvious I'm doing wrong, or is this a bug?
  10. Hello! I just want to make sure there is nothing I am missing before reporting this as a bug. I've created a small test case where a ball go through a wall although it shouldn't because there is the `collide` between the two body materials. I've tried playing with the contactMaterial options without any success. Everything is fine but as a certain velocity where it go through. For instance, if you change the x velocity value to 650, the ball will not go through. Here is the JSFiddle example: https://jsfiddle.net/ygk5dcw4/ I've put a debugger on the "console.log('it overlaps!!!');" on the first occurrence and debugged a bit and the "runNarrowphase" method will return that there is no collision between the ball and the wall. Although, on the second occurrence, the same method returns a collision. Please let me know if I am doing something wrong before I post this as a bug. Thank you very much!
  11. Hey, I'm trying to make a basketball game with predicted trajectory and I am having trouble with the trajectory. chargeBall: function(Pointer, x, y) { // If the button is down we charge the ball. if( Pointer.isDown && !isBallMoving ) { // Clear the graphics, set the style and draw the line from the ball to the Pointer. trajectoryGraphics.clear(); trajectoryGraphics.lineStyle( 2, '0xCCCCCC' ); trajectoryGraphics.moveTo( ball.x, ball.y ); trajectoryGraphics.lineTo( x, y ); // Calculate the velocity variables for the ball body to use in launchBall. launchVelocity.x = ( ball.x - x ) * 5; launchVelocity.y = ( ball.y - y ) * 5; // Make the line narrower. trajectoryGraphics.lineStyle( 1, '0xCCCCCC' ); // Lets make 11 segmented trajectory line. For every segment get the point and draw a small square. for( var i = 0; i < 15; i++ ) { var trajectoryPoint = this.getTrajectoryPoint( ball.x, ball.y, launchVelocity.x, launchVelocity.y, i ); trajectoryGraphics.drawRect( trajectoryPoint.x, trajectoryPoint.y, 2, 2 ); } } }, launchBall: function() { if( !isBallMoving ) { // Clear the graphics if the ball has been launched. trajectoryGraphics.clear(); // Set the ball velocity. ball.body.velocity.x = launchVelocity.x; ball.body.velocity.y = launchVelocity.y; // Flag the ball as moving. isBallMoving = true; // Set the ball physics to enabled. ball.body.data.gravityScale = 1; ball.body.data.collisionResponse = true; // Create a new ball after 4 seconds. this.time.events.add( Phaser.Timer.SECOND * 4, this.createNewBall, this ); } }, getTrajectoryPoint: function( startX, startY, velocityX, velocityY, n ) { var t = 1 / 60; var stepVelocityX = t * this.physics.p2.pxm(-velocityX); var stepVelocityY = t * this.physics.p2.pxm(-velocityY); var stepGravityX = t * t * this.physics.p2.pxm(-this.physics.p2.gravity.x); var stepGravityY = t * t * this.physics.p2.pxm(-this.physics.p2.gravity.y); startX = this.physics.p2.pxm(-startX); startY = this.physics.p2.pxm(-startY); var tpx = startX + n * stepVelocityX + 0.05 * (n * n * n) * stepGravityX; var tpy = startY + n * stepVelocityY + 0.05 * (n * n * n) * stepGravityY; tpx = this.physics.p2.mpx(-tpx); tpy = this.physics.p2.mpx(-tpy); return { x: tpx, y: tpy }; } The code is from Phaser Box2D physics example I think, but I am using the P2 physics system. It works. Kind of. The trajectory is wrong. I am absolutely not sure but I think it has got to do something with the ball physics body. I'd love it if you'd take a quick look and tell me if I'm doing something very wrong.
  12. schmevie15

    [Phaser][WIP] Kirko

    Kirko Tagline: Kirko is about how the worlds we build fit a specific body we deem 'normal' and if you don't fit in the world, things are a lot more difficult for you. Kirko Controls: Left/Right arrow keys to move Up arrow key to jump I have made some progress on my game/interactive story that has been plaguing my head for about a year now. This is a short preview with some of the elements coming together. I am a one man dev team so forgive the crudeness. It's still a work in progress. For the parts where it's long stretches of land I am envisioning having art to keep you busy, for example Circular houses/trees/ etc. Let me know what you think! It's exciting to start seeing my vision come to life! If you support my cause follow me at : Twitter Thanks for playing! P.S Just so you can see the progress: Original demo here: https://dl.dropboxusercontent.com/u/15582110/circle_game/Meteroar.html
  13. 3ddy

    Some help with P2 physics

    Hello, It's my 2nd attempt to physics in game, first in P2. I want to create four lines in something like X shape and rotate it clockwise. Then I will be shooting some little balls and I would like to check if I hit my X obstacle - I do not want to destroy it, apply some gravity to it or more complex physics. On ball collision with my obstacle I just want to kill/destroy that ball. I don't want to move or destroy my obstacle. I've enabled physics at the beginning and created two collision groups game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.setImpactEvents(true); this.ballCollisionGroup = game.physics.p2.createCollisionGroup(); this.obstacleCollisionGroup = game.physics.p2.createCollisionGroup(); I'm spawning my obstacles consisting of 4 lines var dot = game.add.sprite(700, 350, "dot"); dot.anchor.setTo(0.5); this.obstacle.x = 700; this.obstacle.y = 350; var line = game.add.sprite(0, 0, "line"); line.anchor.setTo(0.5, 0); this.obstacle.addChild(line); var line2 = game.add.sprite(0, 0, "line"); line2.anchor.setTo(0.5, 0); line2.angle = 90; this.obstacle.addChild(line2); var line3 = game.add.sprite(0, 0, "line"); line3.anchor.setTo(0.5, 0); line3.angle = -90; this.obstacle.addChild(line3); var line4 = game.add.sprite(0, 0, "line"); line4.anchor.setTo(0.5, 0); line4.angle = 180; this.obstacle.addChild(line4); dot.bringToTop(); this.obstacle.physicsBodyType = Phaser.Physics.P2JS; this.obstacle.enableBody = true; for (var i = 0; i < this.obstacle.children.length; i++) { game.physics.enable(this.obstacle.children[i], Phaser.Physics.P2JS); this.obstacle.children[i].body.angularVelocity = 30; } and my ball this.ball = game.add.sprite(this.activeClock.x, this.activeClock.y, "ball"); this.ball.anchor.set(0.5); game.physics.enable(this.ball, Phaser.Physics.P2JS); this.ball.checkWorldBounds = true; this.ball.events.onOutOfBounds.add(function(){ game.state.start("Intro"); }); this.ballGroup.add(this.ball); this.ball.body.velocity = game.physics.arcade.velocityFromAngle(shootAngle, ballSpeed); this.ball.body.setCollisionGroup(this.ballCollisionGroup); this.ball.body.collides([this.obstacleCollisionGroup], this.ballCollision, this); Right now I'm stucked at spawning my obstacles, because they are spawned on top of eachother and they got hit at spawning and all fall down my game. How to make my obstacles not collide with themselves and apply no gravity to them? Previously I've tried using ARCADE physics but it didn't track the motion of my obstacles in collisions, so I had to change to P2. Thanks in advance for help
  14. Deplicator

    P2 Collisions and Callbacks

    I have a simple space ship shooter game and I have a question about collisions and grouping them. I'm familiar with the collisions groups, impact events and postbroadphase callback P2 examples. Setting collision groups to have ships bounce off walls and each other is like the examples. When I add bullets to a group they bounce around too; off walls and push ships around. The result of the impact happens before the bullet sprite is killed. Bullets act as expected using a postbroadphase callback, but that callback fires anytime anything collides with anything. Is this the correct way to handle this? Is there a way to stop impact events using collision groups? I've googled the hell out of this, but maybe some keyword to point me in the right direction eludes me. Thanks for any help.
  15. (http://g.recordit.co/o5HlkT1d5S.gif) Hi, so my setup involves two hills, where the player is rotated to match the slope angle. The first hill rotates the player to an angle of -45° and the second rotates it to 45°. The problem is that once the second rotates the player, the player can just fall through the bodies. My code for the hills is almost identical. (have a different triangle and angle). I think this might be a bug in p2. Any thoughts? EDIT: I've added a second example: http://g.recordit.co/FLgBsRxbeI.gif In this example we can see that the sprites will slide down the first hill, but upon touching the second they will fall through the wold.
  16. swissnetizen

    P2 moving platform

    Hi! I've been trying to make a moving platform where the player (and other sprites) can ride upon. I tried using something similar to this example (http://jsfiddle.net/pandavigoureux29/zphsz7kp/) to no avail. I've also tried using a contact material and messed with the various friction properties to no avail. I've seen a gravity based solution that ramps up gravity 100x, but I can't use that because of how my game works. Thanks in advance for your help!
  17. Hey guys, I am developing this draft game demo and I need some advice/ feedback on some tips to make the collision a bit better. I'm using loadPolygon to load a custom body shapes for this sprite object and responding to collisions using onBeginContact to applyImpulse to the ball on a SPACEKEY.onDown The following is the code player.body.collides(ballCollisonGroup, this.headerBall, player) headerBall(bodyA, bodyB, shapeA, shapeB, equation) { let duration = 10; let localX = equation[0].contactPointA[0]; let localY = equation[0].contactPointA[1]; let forceX = 0.12 * this.headMass; let forceY = 0.8 * this.headMass; if(this.headerKey.isDown) // only if see is down apply additional force { duration = Math.min(this.headerKey.duration, 500); // apply time based on how long key pressed forceY = (1 * this.headMass).toFixed(2); // apply force of 1 velocity x mass of head (.53) forceX = (1 * this.headMass).toFixed(2); let impulse = [(forceX * duration), (forceY * duration )]; // calculate impulse bodyA.applyImpulse(impulse, localX, localY ); // apply it to ball } } I'm not sure if I am doing it right as I am not verse in Math Physics but i would like some feedback on the following: - Is my formula accuarate? Can I set varying impulses based on the contact shape? There is a sort of glitch if the ball comes into contact with his shoes and the ball ends up in the middle of his body which gets stuck. How can I avoid this? The key down condition seems to be glitchy is there anyway to make this a bit more "safe" to detect and capture? I need to apply some force to the ball ONLY when the space key is pressed. Thank you in advance for your feedback.
  18. schmevie15

    Rotating a square on a hill

    Hey all I have this square I am rotating in my simple plat former and it moves along the straight ground perfectly. I am using: enemy.body.rotateLeft(450); This rotates the enemy perfectly, and moves it along, but I also have these hills in my game and when the enemy square encounters the hill it has a terrible time trying to get up it. Is there some sort of property that I can set that would help with this perhaps mass? Or any ideas on how to resolve this? Thanks! P.S I've attached a picture of the square on the hill for reference. Thanks!
  19. Fractal Games

    Worms Game P2 physics Question (+ demo)

    Hi everyone, I am moving forward on my worms project. I have had a problem with P2 physics for a while that I cannot solve and I need to solve it for impact events. THE DEMO: (Chrome Firefox only) THE REPO: THE PROBLEM: On contact with my level (on a hill) my worm keeps sliding veeeery slowly and annoyingly. If the worm is in contact with the level he should stay still (but he won't). ATTEMPTED: Setting the body of the worm properties: velocity.x =0, velocity.y=0, rotation = 0, angle=0, angularDamping =0, angularVelocity = 0, gravityScale = 0.1 (allowGravityScale = true); Setting the game.physics.p2 properties: friction = 1 (tried 0, 1000, 3000 etc), p2.world.defaultContactMaterial.friction = same thing, restitution = 1; CODE OF INTEREST: WORM CLASS - specifically lines 112-117 GAME STATE Thanks in advance for your help!
  20. Hey, I'm building a top-down parking game, for this game we have levels in JSON which (among other things) determines where the player spawns and at what angle. The player consists of three sprites and three bodies (car and two front wheels) that are positioned relatively to each other. Everything goes well, until I try to spawn the car at an angle, because suddenly I no longer know the x and y coordinates of where to spawn the wheels, and it's a bunch of math to figure that out especially as phaser groups fix this problem. Enter example of my problem #1: https://jsfiddle.net/tv4j4tw1/ What I did here is simply create two sprites in a group, positioned them, positioned the group, and then added a body to the sprites. However the bodies spawn completely out of place. If this actually worked properly I'd have no issues. You can ask why do you even need a group here? I do because of the angles mentioned above, if this group would get an angle it'd be a lot harder to figure out the coordinates of the squares. Now we go into where I tried to hack my way out of this problem: https://jsfiddle.net/tv4j4tw1/1/ Ha! This works, I use the group to position the sprites, and then take the sprites out of the group and position them according to their world position while in the group. It's hacky, but I can live with it. Sadly it stops working once I add the angle (which is the whole reason I'm doing this weird stuff): https://jsfiddle.net/tv4j4tw1/2/ The world position is wrong, and the squares still end up in the wrong place. So, I hope I'm doing something fundamentally wrong and getting the hack to work is a silly idea. Halp.
  21. I have a p2 Object with the following properties this.game.physics.p2.enable(this.player, true); this.player.body.clearShapes(); this.player.body.loadPolygon('playerPolygon','player'); this.player.body.allowRotation = false; this.player.body.fixedRotation = true; this.player.body.immovable = true; this.player.body.setCollisionGroup(playerCollision); this.player.body.collides(ballCollision); this.player.body.kinematic = true; this.player.body.data.shapes[0].sensor = false; this.player.body.collideWorldBounds = true; The above object can only move along its X axis and I want to trigger push/ hit force to its impacting object on collision this.game.physics.p2.enable(this.ball); this.ball.body.setCircle(28); this.ball.body.collideWorldBounds = true; this.ball.body.allowRotation = true; this.ball.body.fixedRotation = false; this.ball.body.adjustCenterOfMass(); this.ball.body.setCollisionGroup(ballCollision); this.ball.body.collides(playerCollision); The above object is always the impacting object whose movement is controlled by gravity and impulse. I'm trying to figure out how to calculate the following:- The point of collision on the body of "this.player" The impulse to apply to the impacting object after collision to simulate a proper/ accurate deflection setting the projected angle and speed/ velocity what properties of the impacting object do I set? Force? AngularVelocity? Velocity?
  22. swissnetizen

    How to check if on Floor using P2?

    Hey, So I need to check whether a sprite is on the floor using P2 physics. Basically something like Arcade.onFloor() but for P2 physics.
  23. Ocelot

    Polygon .json scaling

    Hi, I want to scale both sprite and .json physics file, is that possible and if so, how? I ve seen a few posts about that but no answers. Thank you
  24. HI, I am enthralled by the pixi render texture tutorial, but I'm getting an error from the update() function: I've changed the variable names, but I've triple checked that they are consistent. Here's some of my create() code to give an idea what I'm doing. I was hoping to use the render-texture tutorial on top of my working code. Is there a way to get the renderTexture working within an existing p2 game? Thank you. //game.stage.backgroundColor = "#f2f2f2"; game.world.setBounds(0, 0, 450, 800); game.physics.startSystem(Phaser.Physics.P2JS); // create two render textures.. // these dynamic textures will be used to draw the scene into itself render_texture1 = game.add.renderTexture(450, 800, 'texture1'); render_texture2 = game.add.renderTexture(450, 800, 'texture2'); current_texture = render_texture; // create a new sprite that uses the render texture we created above output_sprite = game.add.sprite(225, 400, current_texture); // align the sprite output_sprite.anchor.x = 0.5; output_sprite.anchor.y = 0.5; stuff_container = game.add.group(); stuff_container.x = 450/2; stuff_container.y = 800/2; // now create some items and randomly position them in the stuff container for (var i = 0; i < 4; i++) { var item = stuff_container.create( Math.random() * 400 - 200, Math.random() * 400 - 200, game.rnd.pick(game.cache.getKeys(Phaser.Cache.IMAGE)) ); item.anchor.setTo(0.5, 0.5); } // used for spinning! count = 0; // Turn on impact events for the world, // without this we get no collision callbacks game.physics.p2.setImpactEvents(true); game.physics.p2.updateBoundsCollisionGroup(); game.physics.p2.gravity.y = 0; game.physics.p2.restitution = 0.7;
  25. The following code produces a flipper and four balls that seem to interact as they should. They all collide with each other and the game world bounds. The problem is that the motor isn't working, nor can I figure out how to limit the rotation of the flipper. The flipper goes to the location of the mouseDown event. It is not fixed to a place on the board. This is my intention. I want to use a flipper wherever the player taps and holds. Thank you. window.onload = function() { var game = new Phaser.Game(800, 300, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.image('flipper', 'assets/sprites/flipper.png'); game.load.image('ball', 'assets/sprites/ball-transparent.png'); // Load our physics data exported from PhysicsEditor game.load.physics('physics_data', 'assets/physics/sprites.json'); } var flipper, flipper_joint, flipper_constraint; var cursors, input_body; var constraint, input_constraint; var constraint_count = 0; var ball1, ball2; function create() { game.stage.backgroundColor = "#f2f2f2"; game.world.setBounds(0, 0, 800, 300); game.physics.startSystem(Phaser.Physics.P2JS); // Turn on impact events for the world, // without this we get no collision callbacks game.physics.p2.setImpactEvents(true); game.physics.p2.updateBoundsCollisionGroup(); game.physics.p2.gravity.y = 10; cursors = game.input.keyboard.createCursorKeys(); // Create our collision groups. One for the flipper, one for the balls var flipper_collision_group = game.physics.p2.createCollisionGroup(); var ball_collision_group = game.physics.p2.createCollisionGroup(); // create joint for flipper flipper_joint = game.add.sprite(200, 150, ''); game.physics.p2.enable(flipper_joint, true); flipper_joint.body.setCircle(25); flipper_joint.body.data.gravityScale = 0; flipper_joint.body.clearCollision(true, true); flipper = game.add.sprite(200, 150, 'flipper'); game.physics.p2.enable(flipper, true); flipper.body.clearShapes(); flipper.body.loadPolygon('physics_data', 'flipper'); flipper.body.data.gravityScale = 0; flipper.body.setCollisionGroup(flipper_collision_group); flipper.body.angle = -35; flipper_constraint = game.physics.p2.createRevoluteConstraint( flipper_joint, [0,0], flipper, [-60,-30] ); input_body = game.add.sprite(0, 0, '', 0); game.physics.p2.enable(input_body, true); input_body.body.setCircle(20); input_body.body.setCollisionGroup(flipper_collision_group); var balls = game.add.group(); balls.enableBody = true; balls.physicsBodyType = Phaser.Physics.P2JS; for (var i = 0; i < 4; i++) { var ball = balls.create(game.world.randomX, game.world.randomY, 'ball'); ball.body.setCircle(25); ball.body.setCollisionGroup(ball_collision_group); ball.body.collides([ball_collision_group, flipper_collision_group]); } // set upper and lower limits for angle in the constraint // NOTE not working flipper_constraint.upperLimitEnabled = true; flipper_constraint.lowerLimitEnabled = true; flipper_constraint.lowerLimit = 0; flipper_constraint.upperLimit = -35; // Not working flipper_constraint.setMotorSpeed(100); } function update() { input_body.body.x = game.input.x; input_body.body.y = game.input.y; if (game.input.activePointer.isDown) { if (constraint_count == 0) { input_constraint = game.physics.p2.createRevoluteConstraint( flipper.body, [0,0], input_body, [0,0], 1000 ); flipper_constraint.enableMotor(); constraint_count = 1; } else if (constraint_count == 1) { flipper_constraint.disableMotor(); game.physics.p2.removeConstraint(input_constraint); constraint_count = 0; } } else { if (constraint_count == 1) { game.physics.p2.removeConstraint(input_constraint); } constraint_count = 0; } } function render() { } }; // end window.onload