Jump to content

Search the Community

Showing results for tags 'resoluteconstraint'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

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 1 result

  1. I'm working on a modified type of pinball, where the flipper appears where the player taps and holds, and flips when the tap is released. I'm not very far along, but I have gotten the flipper to appear where the screen is tapped. However, I'm quite puzzled by how to proceed with revoluteConstraint, getting the flipper to hinge at a certain point. Again, I need to tap the screen to get a flipper, hold the tap and flip the flipper on release. <!doctype html> <html> <head> <meta charset="UTF-8" /> <title>Flipt</title> <script src="assets/phaser.min.js"></script> </head> <body> <script type="text/javascript"> window.onload = function() { var game = new Phaser.Game(800, 600, 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; var cursors; var constraint; function create() { game.stage.backgroundColor = "#f2f2f2"; game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.setImpactEvents(true); var flipperCollisionGroup = game.physics.p2.createCollisionGroup(); var ballCollisionGroup = game.physics.p2.createCollisionGroup(); flipper = game.add.sprite(300, 400, 'flipper'); game.physics.p2.enable(flipper, true); flipper.body.clearShapes(); flipper.body.loadPolygon('physics_data', 'flipper'); flipper.body.kinematic = true; // Modify a few body properties flipper.body.setZeroDamping(); //flipper.body.fixedRotation = true; ground = new p2.Body(); game.physics.p2.world.addBody(ground); pivotCenter = [0, 0]; offsets = [0, 0]; constraint = game.physics.p2.createRevoluteConstraint(flipper, pivotCenter, ground, offsets); constraint.upperLimit = Phaser.Math.degToRad(0); constraint.lowerLimit = Phaser.Math.degToRad(35); constraint.setMotorSpeed(12); constraint.enableMotor(); game.input.onDown.add(toggleFlipper, this); cursors = game.input.keyboard.createCursorKeys(); } function toggleFlipper(pointer) { if (flipper.alive) { flipper.kill(); } flipper.reset(pointer.x, pointer.y); } function update() { flipper.body.setZeroVelocity(); if (cursors.left.isDown) { flipper.body.rotateLeft(50); } else if (cursors.right.isDown) { flipper.body.rotateRight(50); } } function render() { } }; // end window.onload </script> </body> </html> sprites.json
×
×
  • Create New...