Jump to content

The hero pushes a box, pushing another box...


Recommended Posts


I have a problem, and I do not know how to start ...

- phaser
- physics arcade


- a boy, big heroes, with "power" of 100
- a girl, small heroes, with "power" of 50

- big box, weight of 100
- small box, weight of 50
- others types of objects, weight variables

- walls (immovable)


- heroes can push 1 or more objects, but as long as the weight of the objects is less than its force
- example: the boy (power=100) can push 1 object (100), 2 objects (50+50), or any combination of objects, sum(weight) <= 100;

- all = can't push nothing when at least one pushed object is touching a wall (right or left)...

- objects can fall, stopped by walls or others objects (including heroes)

- objects can be stacked but an object can only be on a heavier object
- ex: a small box (w=50) can be on an other small, or on a big one
- ex: a big box (w=100) will crush a smaller one (w=50)
- ex: 2 small boxes will crush the girl (power=50) but not the boy (power=100)


How do I get to settle the physics (collisions) and body parameters of objects/heroes to achieve the rules?

In a collision function, I have try this, it's work for "ONE hero moving ONE box", but I can't find how I can be if their are 2 or more objects...

if (hero.body.touching.right || hero.body.touching.left) {
      if (hero.data.power >= box.data.weight) {
            box.body.moves = true;
      } else {
            box.body.moves = false;
} else {
      box.body.moves = false;


If someone has a clue ...


Link to comment
Share on other sites


  • Recently Browsing   0 members

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