Jump to content

pachinko game physics doesn't work well


enriqueto
 Share

Recommended Posts

I've done a prototype of a pachinko game and collisions doesn't behave as expected (just click on the screen):

 

https://dl.dropboxusercontent.com/u/17484152/PachinkoPrototype/index.html

 

and that's the code:

module PachinkoPrototype {    export class PachinkoScene extends Phaser.State {        public static s_currentPachinkoScene:PachinkoScene ;        create() {            PachinkoScene.s_currentPachinkoScene = this;            this.game.physics.startSystem(Phaser.Physics.P2JS);            this.game.physics.p2.gravity.y = 500;            this.game.physics.p2.defaultRestitution = 2;            this.game.input.onDown.add(this.launch, this);            for (var i = 0; i<5; i++){                for (var j= 0; j< 5; j++){                    var deltaX = j%2 == 0 ? 150:90;                    var pivot = this.add.sprite(deltaX + i *120 ,200 + j *120, 'pivot');                    this.game.physics.p2.enable(pivot, false);                    pivot.body.setCircle(20);                    pivot.body.data.motionState = 2;                }            }        }        launch(){            var ball = this.add.sprite(300,50, 'ball');            this.game.physics.p2.enable(ball, false);            ball.body.setCircle(36);            ball.body.bounce = new Phaser.Point(4,4);        }    }}

any advice?

Link to comment
Share on other sites

It looks ok to me - it just doesn't look anything like pachinko :) You should create a Contact Material that has the sort of properties you want the pegs and ball to exhibit. Then apply the contact material to your pegs and tweak until it feels correct. There is an example showing how to make contact materials that you can copy to get started with. I reckon that is probably all it needs.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...