Sign in to follow this  
dartheater

6 x 6 grid

Recommended Posts

I need to know how to program a really simple 6x6 grid in Phaser - I can't figure out how to do it and I've been trying for ages! I am planning on further developing it with some friends later but I need to get this sorted first 

Share this post


Link to post
Share on other sites

Hi,

If you mean like a grid out of a sprite then...

//create grid group
this.mygridGroup = game.add.group();
this.mygridGroup.enableBody = false;
for (i = 0; i <= 5; i++) {
    for (j = 0; j <= 5; j++) {
        var mygrid = this.mygridGroup.game.add.sprite(50 * j, 50 * i, 'mySprite');
        this.mygridGroup.add(mygrid);
    }
}

//later on you can set properties to the grid like so...
this.mygridGroup.setAll('anchor.x', 0.5);
this.mygridGroup.setAll('anchor.y', 0.5);

img.png

Good luck! :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.