我是电晕的新手,我正在尝试在标签场景中创建一个 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 检查。
我究竟做错了什么?
谢谢