1

「レシピ」の例でディレクトリを使用しようとしています..タイマーに問題があります

ページを実行するmain.luaと、ロゴとウェルカムメッセージが表示され、最初にアプリケーションを使用するときにのみユーザー名とモバイルを取得してtxtファイルに保存する画面があるイントロページに移動する必要があります。次回はそのtxtファイルをチェックします..

次に、ユーザーが選択できる「メニュー」ページに移動します

私の問題は、main.luaI use timer to show the logo, but this timer still work in other screen です。

Main.lua (cdoe)

_w = display.viewableContentWidth
_h = display.viewableContentHeight

 local background = display.newRect(0,0,_w,_h)
 background:setFillColor( 234, 234, 234 ) 

local obj = display.newImage( "ams_logo.jpg" )

-- center the object
obj.x = display.contentWidth*0.5
obj.y = display.contentHeight*0.5

-- fade object to completely transparent
local transition_id = transition.from( obj, { time=2000, alpha=0 } )

--local textObject = display.newText( "Welcome to AMS project", 20, 350, native.systemFont, 24 )
local textObject = display.newText( "Welcome to AMS project", _w*.1, _h*.8, native.systemFont, 24 )
textObject:setTextColor( 255,144,0 )
local transition_id = transition.from( textObject, { time=1500, alpha=0 })

function changeScene (e)
    if(e.phase == "ended") then
        director:changeScene(e.target.scene)
    end

end

local director = require("director");
local mainGroup = display.newGroup();

mainGroup:insert(director.directorView);
display.setStatusBar(display.HiddenStatusBar) _W = display.contentWidth _H = display.contentHeight number = 0

function fn_counter()

director:changeScene("intro");

end
timer.performWithDelay(5500, fn_counter, 0)


the intro .lua 

    module(..., package.seeall)

function new()

    local introGroup = display.newGroup();

        local background = display.newImage("graphics/intro_background.png")

        local begin = display.newImage("graphics/begin_button.png")
        begin.x = 160; 
        begin.y = 400;
        begin.scene = "menu";

        introGroup:insert(background);
        introGroup:insert(begin);

        begin:addEventListener("touch", changeScene);


    return introGroup;

end

私を助けてください ..

4

2 に答える 2

1

関数では

timer.performWithDelay( 5500, fn_counter, 0 ) 

つまり、5500 秒ごとに fn_counter() を呼び出し、無限に何度も実行します (引数が 0 であるため)。それを次のように変更する必要があります

timer.performWithDelay( 5500, fn_counter, 1 )
于 2013-04-12T07:47:03.917 に答える