function fallingCoins()local myPlayer = display.newCircle( math.random(20,_W+20),-25,math.random(10,10) ) myPlayer:setstrokecolor(255,128,0 ) myPlayer:setFillcolor(math.random(245,255),math.random(210,223),7) myPlayer.myname = "myPlayer" physics.addBody( myPlayer,"static" ) myPlayer.y = "150" local function muovi() myPlayer:translate(-2,0) end Runtime:addEventListener( "enterFrame",muovi );endtimer.performWithDelay( 3000,fallingCoins )
如果碰到锚,我就会隐藏硬币.
function onCollision3( event ) if(event.object1.myname == "guy" and event.object2.myname == "myPlayer") then event.object2:removeSelf(); endendRuntime:addEventListener( "collision",onCollision3 )
如果我触摸硬币然后我就会收到此错误
"---------------------------Corona Runtime Error---------------------------...as\desktop\run2\scroll\scrolling background\main.lua:123: attempt to call method 'translate' (a nil value)stack traceback: [C]: in function 'translate' ...as\desktop\run2\scroll\scrolling background\main.lua:123: in function <...as\desktop\run2\scroll\scrolling background\main.lua:122> ?: in function <?:218>Do you want to @R_531_4404@ the project?---------------------------Yes No ---------------------------"
请帮我,我在做错了..
解决方法 translate方法可以应用于显示对象.在这里你的对象也是一个物理,对象.你可以改变有问题的行:
myPlayer.x = myPlayer.x - 2
P.S:但在这种情况下它会快速移动^^
总结以上是内存溢出为你收集整理的lua – 尝试在日冕中调用方法’translet'(零值)全部内容,希望文章能够帮你解决lua – 尝试在日冕中调用方法’translet'(零值)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)