0
刪除特定對象取出幣IM碰撞白衣似乎有點問題即時的得到這個:的碰撞
local screenGroup = self.view
local options2 =
{
--required parameters
width = 16,
height = 16,
numFrames = 8,
--optional parameters; used for dynamic resolution support
sheetContentWidth = 128, -- width of original 1x size of entire sheet
sheetContentHeight = 16, -- height of original 1x size of entire sheet
}
local imageSheet1 = graphics.newImageSheet("items/coin.png", options2)
-- Example assumes 'imageSheet' is already created using graphics.newImageSheet()
-- non-consecutive frames
local sequenceData1 =
{
name="normal",
frames= {1,2,3,4,5,6,7,8}, -- frame indexes of animation, in image sheet
time = 600, --700 -- Optional, in milliseconds ; if not supplied, the animation is frame-based
loopCount = 0 -- Optional ; default is 0
}
local coin = {}
local coinspawn = function()
local i = display.newSprite(imageSheet1, sequenceData1)
i.x = display.contentWidth/2
i.y = display.contentHeight/2
i:play()
i.collided = true
i.name = "coin"
physics.addBody(i, "dynamic",
{density=.1, bounce=0.1, friction=.2, shape= shape2 ,filter=playerCollisionFilter }
)
--player.gravityScale = 0.5
coinIntro = transition.to(i,{time=2000, x=display.contentWidth/2-50 ,onComplete=jetReady , transition=easing.OutExpo }) --
coin[#coin+1] = i
end
timer.performWithDelay(1000, coinspawn, 0)
function coinPlus()
for i = #coin, 1, -1 do
if coin[i] ~= nil then
local function dellcoin()
if coin[i] ~= nil then
coin[i]:removeSelf()
coin[i] = nil
end
end
transition.to(coin[i], { time=100, alpha=0, onComplete = dellcoin})
break
end
end
end
local function onCollision(event)
if event.phase == "began" and gameIsActive == true then
local obj1 = event.object1;
local obj2 = event.object2;
if obj1.name == "playerpop" then
if obj2.name == "BGfrontFL1" then --helper()
elseif obj2.name == "BGfrontFL2" then --helper()
elseif obj2.name == "coin" then coinPlus()
end
end
end
end
Runtime:addEventListener("collision", onCollision)
withs有點兒工作,但它消除了最後催生了硬幣,而不是一個碰撞,如何能我解決這個問題?