作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
通过添加解决
if ( temp.imgpath == "badcloud.png" ) then
physics.addBody( randomcloud, "static", { density=.1, bounce=.1, friction=.2, radius=45 } )
end
============================================= =============================
我想将 physics.addBody
添加到 cloud4 以便它可以与 Runtime:addEventListener("collision", onCollision)
但如果我这样做:
local cloud4 = {}
physics.addBody(cloud4, "static", {densit=.1, bounce=0.1, friction=.2, radius=45})
cloud4.imgpath = "badcloud.png";
cloud4.movementSpeed = 18000;
table.insert(cloudTable, cloud4);
我收到一个错误的参数错误,我该如何解决?
function initcloud()
local cloud1 = {}
cloud1.imgpath = "cloud1.png"; --Set Image Path for cloud
cloud1.movementSpeed = 10000; --Determines the movement speed of cloud
table.insert(cloudTable, cloud1); --Insert cloud into cloudTable
local cloud2 = {}
cloud2.imgpath = "cloud2.png";
cloud2.movementSpeed = 12000;
table.insert(cloudTable, cloud2);
local cloud3 = {}
cloud3.imgpath = "cloud3.png";
cloud3.movementSpeed = 14000;
table.insert(cloudTable, cloud3);
local cloud4 = {}
cloud4.imgpath = "badcloud.png";
cloud4.movementSpeed = 18000;
table.insert(cloudTable, cloud4);
local cloud5 = {}
cloud5.imgpath = "cloud5.png";
cloud5.movementSpeed = 21000;
table.insert(cloudTable, cloud5);
end --END initcloud()
完整代码
function createClouds()
function initcloud()
local cloud1 = {}
cloud1.imgpath = "cloud1.png"; --Set Image Path for cloud
cloud1.movementSpeed = 10000; --Determines the movement speed of cloud
table.insert(cloudTable, cloud1); --Insert cloud into cloudTable
local cloud2 = {}
cloud2.imgpath = "cloud2.png";
cloud2.movementSpeed = 12000;
table.insert(cloudTable, cloud2);
local cloud3 = {}
cloud3.imgpath = "cloud3.png";
cloud3.movementSpeed = 14000;
table.insert(cloudTable, cloud3);
local cloud4 = {}
cloud4.imgpath = "badcloud.png";
cloud4.movementSpeed = 18000;
table.insert(cloudTable, cloud4);
local cloud5 = {}
cloud5.imgpath = "cloud5.png";
cloud5.movementSpeed = 21000;
table.insert(cloudTable, cloud5);
end --END initcloud()
function getRandomcloud()
local temp = cloudTable[math.random(1, #cloudTable)] -- Get a random cloud from cloudTable
local randomcloud = display.newImage(temp.imgpath);
randomcloud.myName = "cloud";
randomcloud.movementSpeed = temp.movementSpeed; -- set the cloud cloudting point
randomcloud.x = math.random(10, _W);
randomcloud.y = -35;
randomcloud.rotation = math.random(0, 20); -- move the cloud
cloudMove = transition.to(randomcloud, {
time = randomcloud.movementSpeed,
y = 500,
onComplete = function(self)
self.parent:remove(self);
self = nil;
end
});
end
function cloudtGame()
cloudTimer1 = timer.performWithDelay(3000,getRandomcloud, 5)
cloudTimer2 = timer.performWithDelay(2000,getRandomcloud, 0)
cloudTimer3 = timer.performWithDelay(2400,getRandomcloud, 0)
cloudTimer4 = timer.performWithDelay(7000,getRandomcloud, 0)
cloudTimer5 = timer.performWithDelay(9000,getRandomcloud, 0)
end--END cloudtGame()
initcloud()
cloudtGame()
end
最佳答案
线
physics.addBody(cloud4, "static", {densit=.1, bounce=0.1, friction=.2, radius=45})
里面有错别字,导致错误。它应该是 density
而不是 densit
。像这样:
physics.addBody( cloud4, "static", { density = .1, bounce = 0.1, friction = .2, radius = 45 } )
关于lua - 添加 '' physics.addBody''本地imgpath lua,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14831648/
var obj = new MyObject(); 我在获取 RestSharp RestRequest.AddBody(obj) 时遇到问题;正确序列化对象。 class MyObject {
我是一名优秀的程序员,十分优秀!