Collision Sprite vs Group

Collision check against a group of objects is performed much in the same way as against a single sprite. First, we set up the game map, putting the blocks at random, of course, enabling physics for all of the objects:

Then, in the source editor, we use this code:

"use strict"; = {
    create: function() {
        this.grass = mt.create('grass');
        this.ball = mt.create('ball');

        //set the velocity and direction of the ball at random
        this.ball.body.velocity.x =, 300);
        this.ball.body.velocity.y =, 300);

    update: function() {
        //add the collision detection
        //in MightyEditor, to interact with group objects that are created by my.create,
        //you must use the .self property, this.grass.self);
        //click to reset {
        }, this);

Full sample available here.

Leave a Reply

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