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