在电晕 SDK 中如何为图像添加标签(文本)
我创建了我的图像如下
local item = display.newImageRect('images/foo.png',70,70);
item.x = 50;
item.y = 50;
Run Code Online (Sandbox Code Playgroud)
如何在图片中添加文字?
非常感谢
你如何在LuaSQLite 3中使用参数化查询?
我试过了解文件:
http://luasqlite.luaforge.net/lsqlite3.html#methods用于准备好的陈述
并看看这里的例子:
但我不能让这个工作:
getTable = function( _key)
local path = system.pathForFile("database.db", system.ResourceDirectory)
local dc = sqlite3.open( path )
local stmt = dc:prepare[[ SELECT * FROM Table WHERE Key = :Key ]]
local sql = stmt:bind({key=_weaponType})
return dc:nrows(sql)
end
Run Code Online (Sandbox Code Playgroud)
我收到错误:
attempt to index 'stmt' (a nil value)
Run Code Online (Sandbox Code Playgroud)
在线上:
local sql = stmt:bind({key=_weaponType})
Run Code Online (Sandbox Code Playgroud)
PS我正在开发Corona SDK游戏.
我正在使用导演类进行场景转换,我需要在另一个类的类中使用该变量.那我怎么称呼呢?
local a= require "welcome"
Run Code Online (Sandbox Code Playgroud)
variableName是welcome类中的文本显示对象
print(a.variableName.text)
Run Code Online (Sandbox Code Playgroud)
但是我没有.
你能救我吗?谢谢
我有石头和苹果等物体连续下落,现在我需要在触摸时消除苹果并得到我触摸的苹果数量....请帮助......我对CORONA全新......这是我的代码:
function newApples()
rand = math.random( 100 )
if (rand < 60) then
j = display.newImage("s1.png");
j.x = 60 + math.random( 160 )
j.y = -100
physics.addBody( j, { density=0.9, friction=0.3, bounce=0.3} )
elseif (rand < 80) then
j = display.newImage("s2.png");
j.x = 60 + math.random( 160 )
j.y = -100
physics.addBody( j, { density=1.4, friction=0.3, bounce=0.2} )
else
apple = display.newImage("apple1.png");
apple.x = 60 + math.random( 160 )
apple.y = -100
physics.addBody( apple, { density=0.3, friction=0.2, bounce=0.5} )
apple.name …Run Code Online (Sandbox Code Playgroud) 我知道 Lua 不完全支持 unicode 但是应该有一种解决方法来解决这个问题?string.reverse 不适用于 unicode,因此以下示例将不起作用
print(string.reverse("????"))
Run Code Online (Sandbox Code Playgroud)
有什么帮助吗?
我正在使用Corona SDK一段时间了,我真的很喜欢它,但有一件事,我无法弄清楚:如何在真实设备上调试我的代码?
在这一点上,当我的代码在模拟器中运行良好时,我通常会编译它,并在手机上尝试它.但是当出现一些错误时,这并不会打扰模拟器,但会关闭手机,我只是看到一条错误消息:
"此应用程序遇到Lua错误(请参阅日志)等."
我和我的老板花了一整天时间搞清楚,我用资本而不是小写来提出要求.
我的问题是:如何实际"看到"该日志?我试图将我的设备连接到DDMS,但我没有看到相关的输出.有没有办法访问该日志(我在Android设备上测试)?或者有没有办法在模拟器中模拟手机的精确行为?通常手机会因为i/o操作以及使用错误的情况而吓坏了.
我有以下代码:
local function RemovePlayer()
print("Something")
end
function change(e)
if(e.phase=="began")then
Player.alpha=1
Player.height=50
Player.width=50
end
if(e.phase=="moved")then
angle=(math.atan2( (e.y - Player.y), (e.x - Player.x))*180)/math.pi +90
Player.rotation=angle
end
if(e.phase=="ended")then
transition.to(Player,{time=200,height=32,width=32})
local xx = (e.x-Player.x)*2
local yy = (e.y-Player.y)*2
Player.bodyType = "dynamic"
Player:applyForce( xx, yy, Player.x, Player.y )
timer.performWithDelay ( 10000,RemovePlayer() )
end
return true
end
Run Code Online (Sandbox Code Playgroud)
问题是timer.performWithDelay看起来似乎不正确,因为"Something"在结束阶段之后立即打印在控制台中而不是10000延迟.知道为什么会这样吗?
我试图将一个函数作为参数传递给另一个函数.
高级别我有代码创建一个弹出窗口.当我用新文本更新弹出窗口时,我还想更新用户单击弹出窗口时发生的操作.例如,我第一次更新弹出窗口时,我可能会将Action更改为再次使用新文本显示弹出窗口.当用户点击第二个时
下面是一些示例代码来说明这个概念
function doSomething()
print("this is a sample function")
end
function createPopup()
local popup = display.newRect ... create some display object
function popup:close()
popup.isVisible = false
end
function popup:update(options)
if options.action then
function dg:touch(e)
-- do the action which is passed as options.action
end
end
end
popup:addEventListener("touch",popup)
return popup
end
local mypopup = createPopup()
mypopup:update({action = doSomething()})
Run Code Online (Sandbox Code Playgroud) 在某些函数调用中我们使用“.”。运算符,而有些我们使用“:”,它们之间有什么区别。例子:storyboard:addEventLsitener(something,something)
graphics.newImageSheet(something,something)
我正在创建我的第一个iPhone游戏,无法弄清楚如何重新加载我的游戏.
我正在使用coronaSDK并尝试使用他们的composer API.当玩家死亡时,出现一个"再次播放"的按钮,当他触摸它时,我将他引导到一个名为"reload.lua"的场景中composer.gotoScene("reload").
在这个场景中,我有以下代码:
function scene:show(event)
local sceneGroup = self.view
local phase = event.phase
if (phase == "will") then
elseif (phase == "did") then
local replay = display.newImage('star1.png', 100, 300)
composer.removeScene("level1")
composer.gotoScene("level1")
end
end
Run Code Online (Sandbox Code Playgroud)
但是,这仅level1在现有的基础上添加,并且不会删除已使用的那个.关于如何成功删除level1或重新加载我的游戏的任何想法?