STeN
STeN

Reputation: 6268

Corona - "bad argument #-2 to 'insert'"

There is a great tutorial how to wrap the DisplayObject in the “proxy” - it is necessary since due its native background the DisplayObject cannot be “inherited”. It all works just fine, but whatever I tried I am still getting an error

bad argument #-2 to 'insert'

When I try to insert the created object into DisplayGroup:

self.view:insert(fish)

Can anyone help there? After several hour of experiments I am off.

Upvotes: 0

Views: 988

Answers (2)

Mustafa
Mustafa

Reputation: 150

Look for the display group name. If you are using storyboard then:

function scene:createScene( event )
    -- The display group is named "group" or any name you want
    local group = self.view

    local fish = display.newText("Fish!", 0, 0, native.systemFont, 16)

    -- insert your string or image to the display group
    group:insert(fish)
end

Upvotes: 0

DevfaR
DevfaR

Reputation: 1616

if i'm not mistaken you are trying to insert a word/string to a display group or maybe the group that you are inserting does not exist have you try to insert group just like this

group:insert(fish)

instead of this

self.view:insert(fish)

if you did try refer to this link

Upvotes: 1

Related Questions