Jump to content

Trying to display polygons throws an unexpected error


noodlesdefyyou
 Share

Recommended Posts

I've finally figured out collision! I'm going through and setting vertex points for my polygons, then added render: render to the var game line at the very top.

 

function render()
    {
        game.debug.renderPhysicsBody(player.body);
        //game.debug.renderPhysicsBody(Drone1.body);
        //game.debug.renderPhysicsBody(pBlasters.body);
        //game.debug.renderPhysicsBody(eBlasters.body);
    }

 

I was able to get my player polygon to display perfectly. However, when I try to display another polygon (uncomment that second line), it tells me 'TypeError: body is undefined phaser.js 37799'.

 

Drone1 is the variable i've applied the polygon to. I've even gone and renamed 'Drone1' to anything else it could possibly be, and whenever I change it, I get the 'x is not defined' error. So I know I have the right variable.

 

The only thing I can think of is Drone1 is a created group, instead of an individual sprite, which is this code:

 

    function createDrone1()
    {
        for (var y = 0; y < 1; y++)
        {
            for (var x = 0; x < 10; x++)
            {
                var drones1 = Drone1.create(x * 32, y * 50, 'drone1');
                drones1.anchor.setTo(0, 0);
                drones1.body.setPolygon(1, 14, 11, 17, 11, 2, 21, 2, 21, 17, 31, 14, 31, 42, 29, 49, 27, 35, 22, 30, 16, 36, 10, 30, 5, 35, 3, 50, 1, 39);
            }
        }
    }

 

Assuming this code is correct, it should apply that polygon to each created sprite. Am I overlooking something here? Why am I unable to display a second debug render?

 

Link to comment
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...
 Share

  • Recently Browsing   0 members

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