bad argument #-2 to 'insert' proxy expected got nil

Hy people!
My name is Franz, i’m from Brazil and I’m trying to develop a game.
Everything was well… till this week haha.

I’m trying to create an instance of a class (called Enemy1).
In my code, I do this:

local enemy = Enemy1:new()
localGroup:insert(enemy)

When I do this, I got the erro: “bad argument #-2 to ‘insert’ proxy expected got nil”.

Somebody helps my, please =(

My Enemy1 class:
Enemy1 = newclass(“Enemy1”)

function Enemy1:new(Xpos)
local enemy = display.newImage(“dEnemy1.png”);
enemy:setReferencePoint(display.CenterReferencePoint);
enemy.x = Xpos;
enemy.y = -enemy.contentHeight;

local physics_body_e1 = {};
physics_body_e1[“enemy”] = {
{
shape = { -16, -24 , -43, -18 , -42, -26 , -36, -33 , -30, -36 , -22, -36 }
},{
shape = { 62, 29 , 59, 32 , 46, 36 , 33, 36 , 12, 29 , 43, 19 , 60, 24 , 62, 26 }
},{
shape = { -66, -2 , -8, 32 , -41, 32 , -61, 28 , -69, 24 , -75, 17 , -74, 5 }
},{
shape = { 73, 20 , 61, 20 , 56, 18 , 69, 8 , 75, 14 , 75, 18 }
},{
shape = { 52, -12 , 42, -7 , 42, -9 , 46, -12 }
},{
shape = { 71, -22 , 75, -12 , 69, 8 , 56, 18 , 54, 15 , 52, -12 , 53, -15 , 60, -21 }
},{
shape = { 75, -12 , 71, -22 , 74, -20 }
},{
shape = { -43, -18 , -16, -24 , -13, -21 , -58, -4 , -55, -10 , -50, -15 }
},{
shape = { 20, -12 , -58, -4 , 10, -15 , 14, -15 }
},{
shape = { 12, 29 , 5, 29 , -66, -2 , 40, 16 , 43, 19 }
},{
shape = { -66, -2 , 5, 29 , -8, 32 }
},{
shape = { 7, -17 , 10, -15 , -58, -4 , -13, -21 }
},{
shape = { 39, -7 , -66, -2 , -58, -4 , 20, -12 , 24, -12 }
},{
shape = { 40, 16 , 42, -7 , 52, -12 , 54, 15 }
},{
shape = { -66, -2 , 39, -7 , 42, -7 , 40, 16 }
}
}
physics.addBody(enemy, unpack(physics_body_e1[“enemy”]));

return enemy;

end;

return Enemy1;

And my main.lua:
require (“enemy1”)
function addEnemy()
if(gameActive == true)then
if(countOfEnemies < 30)then
local enemy = Enemy1:new();
enemies:insert(enemy); --that’s my local group
end
end
end

Thanks!
[import]uid: 132387 topic_id: 27602 reply_id: 327602[/import]