【问题标题】:Slideshow forward code overriding back button code幻灯片前进代码覆盖后退按钮代码
【发布时间】:2015-10-06 17:44:54
【问题描述】:

scene1中的这段代码...

local composer = require ( "composer")
  local scene = composer.newScene()

    local function showScene2()
            local options = {
                effect = "slideLeft",
                    time = 130,
                    }
  composer.gotoScene("scene2", options)
  end

...正在覆盖此代码,也在 scene1...

local object = display.newImage("images/goBackBtn.png", 240, 250)
  object.name = "button object"

  local function onObjectTap( self, event )
  composer.gotoScene( "firstBar1" )
        return true
            end
  object.tap = onObjectTap
  object:addEventListener( "tap", object )
  sceneGroup:insert( object )

后退按钮有效。它显示了 firstBar1 场景,但只是瞬间。

然后下一个场景,scene2,出现在屏幕上,幻灯片继续播放。 (顺序为firstBar1、scene1、scene2、scene3等)。所有场景都有一个返回到 firstBar1 的按钮。

为什么幻灯片不会回到 firstBar1 并停在那里?我该如何纠正?

这与一位评论员建议我澄清的先前查询有关:“后退按钮无法导航到所需场景”。

谢谢。

【问题讨论】:

    标签: lua slideshow coronasdk back-button


    【解决方案1】:

    可能是因为您在 firstBar 场景上执行了计时器。如果是这样,每次显示 firstBar1 场景时,您都会调用 showScene2 函数()..所以每次返回场景时都会执行计时器。 . 我建议你在点击后退按钮停止计时器时传递一个参数,甚至决定是否使用计时器。

    所以我会添加到后退按钮

     local function onObjectTap( self, event )
      composer.gotoScene( "firstBar1",{params = {timer = "stop"} )
       return true
      end
    

    在第一个酒吧场景

    local params = event.params
    
    if (params.timer ~="stop") then
    timer.performWithDelay(2000, showScene2 )
    end
    

    【讨论】:

    • 谢谢。我试过这个,但不能让它工作。 firstBar1 没有计时器,只是一个将其发送到场景 1 的前进按钮。这个代码可以修改吗? if (params.timer ~="stop") then timer.performWithDelay(2000, showScene2 ) 我试过但没有成功。谢谢。
    猜你喜欢
    • 2013-08-27
    • 1970-01-01
    • 1970-01-01
    • 2014-02-02
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    相关资源
    最近更新 更多