我有一个图像(地面),顶部有透明像素,因为地面有起伏的山丘......问题是球根据山丘没有向下和向上移动......球只漂浮在图像上。我该怎么办?
local bg2 = display.newImage("images/ground.png",true)
bg2:setReferencePoint(display.CenterLeftReferencePoint)
bg2.x = 0; bg2.y = _H/1.25;
local physics = require("physics")
physics.start()
local redOrb = display.newCircle( 0, 0, 25)
redOrb:setFillColor(255,0, 0)
physics.setGravity(0,9.8)
redOrb.x = 180; redOrb.y = 190; redOrb.rotation = 5
physics.addBody( bg2, "static", { friction=0.5, bounce=0.3 } )
physics.addBody( redOrb, { density=3.0, friction=0.5, bounce=0.3 } )
答案 0 :(得分:2)
当您向具有透明度的图像添加正文时,它不会自动将正文作为图像本身。
您可以将此工具用于物理主体
http://www.codeandweb.com/physicseditor
http://www.codeandweb.com/blog/2012/05/24/getting-started-with-coronasdk-and-physicseditor-tutorial
要查看实际的物理主体,您可以添加此代码
physics.setDrawMode("hybrid")