Whats wrong with my rect?

Hi, guys, i have problem : my rectangles dont want draw themselves. I dont see any mistakes in my code and im very tired. What must i correct in my class?


--# Main

displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
    enemy1 = Horde()
    
    hw = WIDTH/2
    hh = HEIGHT/2
    
    ball = physics.body(CIRCLE,20)
    ball.x = 1
    ball.linearVelocity = vec2(1200,0)
    ball.y = hh 
    
    points = {vec2(0,0),vec2(0,500/6),vec2(50,500/6),vec2(0,0),vec2(50,0),vec2(50,500/6)}
    --pointstex = {vec2(0,0),vec2(1,0),vec2(0,1),vec2(0,1),vec2(1,1),vec2(1,0)}
   
    mainhero = physics.body(POLYGON,unpack(points))
    mainhero.x = hw
    mainhero.y = hh
    mainhero.gravityScale = 1
    
    colors = {color(255, 0, 0, 255),color(0, 255, 0, 255),color(0, 0, 255, 255),color(255, 0, 0, 255),color(0, 255, 0, 255),color(0, 0, 255, 255)}
    
    heromesh = mesh()
    heromesh.vertices = {unpack(points)}
    heromesh.colors = {unpack(colors)}
    
    
    floor =  physics.body(EDGE,vec2(0,-3),vec2(WIDTH,-3))
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(127, 127, 127, 255)
    pushMatrix()
    
    
    translate(mainhero.x,mainhero.y)
    rotate(mainhero.angle)
    heromesh:draw()
   -- sprite("Documents:mainHero",0,0,50,500/6)
    
    popMatrix()
    fill(255, 2, 0, 255)
   
    -- rect(floor.x,floor.y,WIDTH,10)
  
     -- rect(mainhero.x,mainhero.y,50,500/6)
    --[[ pushMatrix()
    
    rotate(mainhero.angle)
    
    popMatrix() ]]--
    enemy1:draw()
    
  ellipse(ball.x,ball.y,40)
    -- Do your drawing here
    
end

--[[function touched(t)
    if t.state == ENDED then
        physics.resume()
    end
    if t.state == MOVING then
        restart()
    end
end ]]--

--# Horde
Horde = class()

function Horde:init()
    -- you can accept and set parameters here
    self.horde = {}
    
--meshes dont want draw too
        
  --[[  self.enemymesh = mesh()
    self.enemymesh.vertices = {}
    self.enemymesh.colors = {} ]]--
end

function Horde:enemy()
    self.enemy = physics.body(POLYGON,vec2(0,0),vec2(0,500/6),vec2(50,500/6),vec2(0,0),vec2(50,0),vec2(50,500/6))
    self.enemy.x = touch.x
    self.enemy.y = touch.y
    self.enemy.type = DYNAMIC
    table.insert(self.horde,enemy)
end

function Horde:draw()
    pushStyle()
    fill(255, 157, 0, 255)
    for k,v in pairs(self.horde) do
        rect(v.x,v.y,50,500/6)
    end
    popStyle()
end

function Horde:touched(touch)
    -- Codea does not automatically call this method
    if touch.state == BEGAN then 
        Horde:enemy()
    end
end

@lupion8211 When I run this, I see a ball going across the screen and hitting a rectangle that spins and lands on the bottom of the screen. What’s supposed to happen after that, that isn’t happening.

@dave1707 oh. Im absolutely forget about describing my problem. I need to draw physics body (rectangle) there touch the screen. Like in opening of cargobot

@lupino8211 The code you have in Horde:enemy should be moved to Horde:init. Then in the touched(t) routine, you create an instance of Horde at the point you touch the screen instead of trying to create it in Horde:touched(t) which isn’t being called at all.

@dave1707 thank you . I will test it