0

関数をオーバーライドしてパラメーター値を検査したいのですが、それを呼び出して元のパラメーターを通常どおり渡します。これは可能ですか?www.coronalabs.comのCorona SDKを使用しています

現在、動作しない私のコードは次のとおりです。

-- getting a refrence to the original function so i can replace it with my overriding function
local newcircle = display.newCircle

-- my override
display.newCircle = function(...)
-- attempt to pass the parameters to this function on to the real function
local t = {...}
newcircle(unpack(t))
end

-- calling the overridden function as if it were normal
display.newCircle( display.newGroup(), "image.png" )
4

1 に答える 1

1

新しいdisplay.newCircle実装では、未定義のtテーブルと非推奨のarg自動テーブルを使用しています。

これを試して :

-- my override
display.newCircle = function(...)
    local t = {...} -- you need to collect arguments to a table
    -- dumb use of override
    print(t[1])
    -- attempt to pass the parameters to this function on to the real function
    newcircle(unpack(t))
end
于 2012-11-08T09:57:05.287 に答える