JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.danielboa.com/test/phaser-tilesprite-bug/bower_components/phaser/build/phaser.js"></script>
<div class="game-container"></div>
JavaScript
var small_boxes;
var big_boxes;
var small_box_collision_group;
var big_box_collision_group;
var game = new Phaser.Game(300, 300, Phaser.AUTO, '.game-container', {
preload: function () {},
create: function () {
var i;
var small_box_temp;
var big_box_temp;
// start p2 physics system
game.physics.startSystem(Phaser.Physics.P2JS);
game.physics.p2.gravity.y = 500;
game.physics.p2.setBoundsToWorld(true, true, false, true, true);
// create collision groups
small_box_collision_group = game.physics.p2.createCollisionGroup();
big_box_collision_group = game.physics.p2.createCollisionGroup();
// create and populate static box group
big_boxes = game.add.group();
for (i = 0; i < 2; i++) {
big_box_temp = game.add.sprite(game.world.randomX, game.world.height / 1.5, 'test', null, big_boxes);
big_box_temp.width = 50;
big_box_temp.height = 50;
big_box_temp.inputEnabled = true;
big_box_temp.events.onInputDown.add(boxClickHandler, big_box_temp);
game.physics.p2.enable(big_box_temp);
// they still collide after reset if static is 'false'
big_box_temp.body.static = true;
big_box_temp.body.angle = 45;
big_box_temp.body.setCollisionGroup(big_box_collision_group);
big_box_temp.body.collides([small_box_collision_group]);
}
// create and populate dynamic box group
small_boxes = game.add.group();
for (i = 0; i < 10; i++) {
small_box_temp = game.add.sprite(game.world.randomX, 20, 'test', null, small_boxes);
small_box_temp.width = 20;
small_box_temp.height = 20;
game.physics.p2.enable(small_box_temp);
small_box_temp.body.setCollisionGroup(small_box_collision_group);
...