event.phase事件階段
Description:
Specifies the collision phase and can be one of the following values:
指定碰撞階段,可以是以下值:
"began" -- Indicates a collision between two bodies has started initial contact.
"ended" -- Indicates a collision between two bodies has completed.
“開始“- 表示這兩個機構之間的碰撞已經開始初步接觸。
“結束“- 表示這兩個機構之間的碰撞已經完成。
Syntax:
event.phase
Example:
--------------------------------
local crate1 = display.newImage( "crate.png", 100, 200 )
physics.addBody( crate1, { density = 1.0, friction = 0.3, bounce = 0.2 } )
crate1.myName = "first crate"
local crate2 = display.newImage( "crate.png", 100, 120 )
physics.addBody( crate2, { density = 1.0, friction = 0.3, bounce = 0.2 } )
crate2.myName = "second crate"
local function onCollision( event )
if ( event.phase == "began" ) then
print( "began: " .. event.object1.myName .. " & " .. event.object2.myName )
elseif ( event.phase == "ended" ) then
print( "ended: " .. event.object1.myName .. " & " .. event.object2.myName )
end
end
Runtime:addEventListener( "collision", onCollision )
---------------------------------
Parameters:
None.
Returns:
Nothing.
Remarks:
Note: The objects involved in the collision should not be removed or any of it's properties altered during a collision event. You should use timer.performWithDelay() if they want to modify object position values or other properties within the collision events.
注:參與的對象碰撞不應刪除或它的任何屬性的改變在發生碰撞時。您應該使用timer.performWithDelay()如果他們想修改對象位置值或其他財產在碰撞事件。
Removing the object or modifying the properties in the collision event could cause the simulator to crash.
刪除或修改對象的屬性在發生碰撞時可能會導致模擬器崩潰。
Supported on operating systems and platforms for build numbers shown:
Mac OS X:Build 2010.222
Windows: Build 2010.222
iOS: Build 2010.222
Android: Build 2010.222
Related:
- May 18 Wed 2011 13:39
Corona event.phase事件階段
close
全站熱搜
留言列表