【发布时间】:2013-02-11 03:34:35
【问题描述】:
我是电晕的新手,我正在尝试在选项卡场景中创建一个 gps。我创建了一个局部变量 loc,它将放置位置数据字符串
local loc = "Loading" -- as initial value
then a location handler put a new value to it
local function locationHandler( event )
...
loc = "the gps location"
end
function scene:createScene( event )
local group = self.view
-- create a white background to fill screen
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg:setFillColor( 255 ) -- white
local title = display.newRetinaText(loc, 0, 0, native.systemFont, 20 )
-- this is where the loc is placed in the title
title:setTextColor( 0 ) -- black
title:setReferencePoint( display.CenterReferencePoint )
title.x = display.contentWidth * 0.5
title.y = 170
end
问题是 loc 在设备中运行时仍然包含“正在加载”,但它在模拟器中工作。我已经检查过,gps 工作正常,应该放在 loc 变量中的文本已准备好进入内部处理程序,使用 logcat 检查。
我做错了什么?
谢谢
【问题讨论】:
-
忘记了,但是位置处理程序也有这一行 -- 激活位置侦听器 Runtime:addEventListener( "location", locationHandler )
-
还尝试将静态文本放在位置处理程序 loc = "some other text" 中,并且 Loading 仍然是显示的文本,因此我可能在更改变量的值时出错
-
我已经推断出在位置处理程序内部设置值是问题,因为我尝试将值更改放在处理程序外部并且它可以工作。但是我需要位置的值,尝试过的模块仍然无法使用我应该使用数据库吗?
-
显然您的 locationHandler 函数根本不起作用,或者在您想要的行之前停止。想发布日志吗?
标签: android coronasdk corona-storyboard