Overlap Sprite vs Group

To check overlapping for sprite vs group or group vs group, you must first enable physics for the placed objects.


"use strict";
"use strict";
window.OverlapGroup.state.menu = {
    create: function() {
        //create all objects and enable mouse drag on the box
        this.grass = mt.create("grass");

        this.box = mt.create("box_simple");
        this.box.inputEnabled = true;

        this.text = mt.create("Text");

    update: function() {
        //set text to blank

        //if the box overlaps any of the grass sprites, callback function sets different text
        this.game.physics.arcade.overlap(this.box, this.grass.self, function(box, grass) {
        }, null, this);

Mouse drag the box over any of the grass sprites.

Full sample available here.

One thought on “Overlap Sprite vs Group

  1. I just wanted to coemmnt and say that I really enjoyed reading your blog post here. It was very informative and I also digg the way you write! Keep it up and I’ll be back to read more in the future

Leave a Reply

Your email address will not be published. Required fields are marked *