lua绑定中如何继承sprite

我想创建一个类Player继承Sprite,达到的效果是直接 local player = Player.create()就可以生成一个对象。代码如下:

local Player = class("Player", function()
    return cc.Sprite:create()
end)

function Player.create()
    local player Player.new()
    return player
end

function Player:ctor()
    self.super.ctor(self, 'player.png')

    -- 其他初始化代码
end

return Player

```


可是编译的时候报错,说不存在super成员,这是怎么回事?应该怎么正确地继承呢?

谢谢

没人回答么

sprite最好create的时候就进行初始化,你可以参考下
http://blog.csdn.net/chiuan/article/details/8531975

local Player = class(“Player”, function(filename)
return cc.Sprite:create(filename)
end)

function Player.create(filename)
local player = Player.new(filename)
return player
end

function Player:ctor()

-- 其他初始化代码

end

return Player

你这样的话我在创建对象的时候还是要传入图片路径。

我想把图片路径直接封装在构造函数了,创建对象的时候直接create()就行了,这样能实现不?

local Player = class(“Player”, function()
return cc.Sprite:create(‘player.png’)
end)

function Player.create()
local player = Player.new()
return player
end

function Player:ctor()

-- 其他初始化代码

end

return Player

留下你qq

local Player = class(“Player”, function(path)
return cc.Sprite:create(path)
end)

function Player.create(path)
local player = Player.new(path)
return player
end

function Player:ctor()

-- 其他初始化代码

end

return Player