I wanna make a plugin where someone calls a function passes some info along with the call and makes a listenerfunction, the function has to look like this:
database.execute(database.Update)
:data({username="Jhon"})
:response(function(responseString, responseTable)
///
end)
Run Code Online (Sandbox Code Playgroud)
I know how to make a basic function call like this database.execute(_, _, _) but have no idea how to make it multi-line operation like this
database.execute()
:_()
:_()
Run Code Online (Sandbox Code Playgroud) 在我的game.lua文件中我有这个:
function new()
local obj = display.newGroup();
currentLevel = Level.new(1);
currentLevel.game = obj; //also tried currentLevel.game = self;
function obj:replay()
print("game - replay")
end
return obj;
end
Run Code Online (Sandbox Code Playgroud)
在Level lua文件中,我尝试在game.lua中调用重播函数:
game = {};
...
game:replay();
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:尝试调用方法'重放'(一个零值)
如何在level.lua中保留对游戏文件的引用?
我是Lua的新手,所以(很自然地)我遇到了我试图编程的第一件事.我正在使用Corona Developer软件包提供的示例脚本.这是我试图调用的函数的简化版本(删除了无关材料):
function new( imageSet, slideBackground, top, bottom )
function g:jumpToImage(num)
print(num)
local i = 0
print("jumpToImage")
print("#images", #images)
for i = 1, #images do
if i < num then
images[i].x = -screenW*.5;
elseif i > num then
images[i].x = screenW*1.5 + pad
else
images[i].x = screenW*.5 - pad
end
end
imgNum = num
initImage(imgNum)
end
end
Run Code Online (Sandbox Code Playgroud)
如果我尝试像这样调用该函数:
local test = slideView.new( myImages )
test.jumpToImage(2)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
尝试将数字与零比较
在第225行.似乎"num"没有被传递到函数中.为什么是这样?
我正在从Corona的示例代码中分析Fishies projest,我无法理解该任务.
background = ( backgroundLandscape == background and backgroundPortrait ) or backgroundLandscape
Run Code Online (Sandbox Code Playgroud)
这是完整的代码:
-- Seed randomizer
local seed = os.time();
math.randomseed( seed )
display.setStatusBar( display.HiddenStatusBar )
-- Preload the sound file (theoretically, we should also dispose of it when we are completely done with it)
local soundID = audio.loadSound( "bubble_strong_wav.wav" )
-- Background
local halfW = display.viewableContentWidth / 2
local halfH = display.viewableContentHeight / 2
-- Create a table to store all the fish and register this table as …Run Code Online (Sandbox Code Playgroud) 我试图理解Corona中的那些参考点.据说默认参考点是对象的中心,但是当我运行此代码时,textObject中心的x位置不是100而是150
local textObject = display.newText( "Hello World!", 100, 100, nil , 20 )
Run Code Online (Sandbox Code Playgroud)
我在屏幕上显示了触摸事件的位置并打印了触摸位置的x和y位置:
local function onScreenTouch(event)
print("x: "..event.x.." y: "..event.y);
end
Runtime:addEventListener("tap", onScreenTouch)
Run Code Online (Sandbox Code Playgroud) Corona SDK的新手,我正在试图找出一种在模拟器上加载和保存文件(存储游戏数据)的方法.(我不想在真实设备上进行调试,每次只需要15秒才能看到变量).
我按照这里的教程:http://www.coronalabs.com/blog/2011/08/03/tutorial-exploring-json-usage-in-corona/ ,在找不到解决此问题的stackoverflow上找不到任何内容.
现在我有以下代码用于读取和存储文件:
local readJSONFile = function( filename, base )
-- set default base dir if none specified
if not base then base = system.ResourceDirectory; end
-- create a file path for corona i/o
local path = system.pathForFile( filename, base )
-- will hold contents of file
local contents
-- io.open opens a file at path. returns nil if no file found
local file = io.open( path, "r" )
if file then
-- read all …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个字符串分成两部分,用一个'.'字符分隔.但string.find()功能无法处理
我有这种字符串
local test = "345345.57573"
Run Code Online (Sandbox Code Playgroud)
我试过了
local start = string.find( test, "." )
local start = string.find( test, "\." )
local start = string.find( test, "(%w+).(%w+)" )
Run Code Online (Sandbox Code Playgroud)
但它们都没有奏效.String.find()总是返回1false.可能是什么问题?
编辑:我也尝试使用gsub和更改.与另一个角色,但它也没有工作
我正在尝试使用storyboard.showOverlay()在按钮单击事件上显示一个弹出窗口,这只是另一个场景的场景.是否有任何功能可以显示正确的弹出窗口?
好吧所以我确定错误是真的很蠢,但由于某种原因我无法得到它,所以我非常感谢一些帮助:)
local function Selector()
x = math.random(1,2)
if x == 1 then
Veshtica
end
end
Run Code Online (Sandbox Code Playgroud)
"Veshtica"是我想要打电话的功能.错误消息 - ""="预计接近结束"
coronasdk ×10
lua ×7
function ×1
love2d ×1
lua-patterns ×1
mobile ×1
persistence ×1
popupwindow ×1
reference ×1
string ×1