0
local car={};
local car_mt = { __index=car };
function car.new(_x, _y,_color,_animation_index)
local ncar=
{
x=_x or 0;
y=_y or 0;
color=_color or 0x005500;
print(_animation_index,animation_index);
animation_index=(_animation_index or 1);
print((_animation_index or 1),animation_index);
}
return setmetatable(ncar,car_mt);
end
return car;
零零
1零
_Color并且当car.new是_animation_index没有定义所谓:
local pcar=require("car")
...
function scene:enterScene(event)
local group = self.view
physics.start();
local car1=pcar.new(200,200);
end
为什么在分配后没有更改animation_index值?
UPD: 我不能用类似rranimation_index这样的名称来指定变量。
rranimation_index=(_animation_index or 1);
rranimation_index=5;
print((_animation_index or 1),rranimation_index);
是:
1零
这是不可能减去已使用全局变量的名称引起的。
本地附近的意外符号 – user2136963 2013-03-10 15:04:46
首先解决编译器错误。 – 2013-03-10 21:56:03