在 CoronaSDK 上显示图像需要多长时间?

我正在使用 Corona 组件,并想知道是否有一种方法可以知道图像何时完全加载。 我在 main.lua 中有以下代码:

local widget = require( "widget" )

local function onSystemEvent(event)
    if event.type == "applicationStart" then

        initial = os.clock()
        local myImage = display.newImage("image.jpg", 500, 500)
        final = os.clock()
        time = final - initial;
        native.showAlert("tiempo ", time )
    end
end

Runtime:addEventListener("system", onSystemEvent)

我想测量加载图像需要多长时间...但我的代码输出只有 0.003 秒,所以我猜这不是实际时间。

你们有什么想法吗?

点赞
用户3041972
用户3041972

尝试截屏:

local function captureWithDelay()
    local capture = display.captureScreen()
end

timer.performWithDelay( 1, captureWithDelay )

然后读取最后一个像素颜色。

local function onColorSample( event )
    print( "采样像素在位置 (" .. event.x .. "," .. event.y .. ")" )
    print( "R = " .. event.r )
    print( "G = " .. event.g )
    print( "B = " .. event.b )
    print( "A = " .. event.a )

    print( system.getTimer() )
end

display.colorSample( x, y, onColorSample )

然后比较结果以找出颜色何时发生变化。

2016-12-25 05:56:27