Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Physics.P2 moving sprite


Recommended Posts

Hello everybody!

I'm having trouble.

I do for yourself the game, and I need to have the tank cars are not repelled from himself but only pushed without accelerating.

An example can be seen here


Part of the tank code:

this.tank = game.add.sprite(x, y, 'tank');

Part of the car code:

groupCar = game.add.group();
groupCar.enableBody = true;
groupCar.physicsBodyType = Phaser.Physics.P2JS;

for (var p = 0; p < map[id][position].length; p++) {

    name = map[id][position][p].name
    x = map[id][position][p].x
    y = map[id][position][p].y

    sprite = groupCar.create(x, y, name);

    sprite.id = id;
    sprite.angle = map[id][position][p].angle;
    sprite.static = map[id][position][p].static;

groupCar.forEach(function(car) {
        car.body.collides([playerCollisionGroup, bulletCollisionGroup, carCenterCollisionGroup]);
        car.body.static = car.static;
        car.body.angle = car.angle;
        car.body.kinematic = false;


In the documentation, or in the examples I have not found help, I hope you help me



Sorry for my bad english:(

Link to comment
Share on other sites


  • Recently Browsing   0 members

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