写游戏的人都知道碰撞检测,Phaser直接封装好了函数供我们调用,请看
Phaser.Physics.Arcade.collide(object1, object2, collideCallback, processCallback, callbackContext)
各参数意义如下,看来我们能用回调函数collideCallback做许多事儿~
The Arcade Physics world. Contains Arcade Physics related collision, overlap and motion methods. class Phaser.Physics.Arcade { Checks for collision between two game objects. You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions. Both the first and second parameter can be arrays of objects, of differing types. If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. The objects are also automatically separated. If you don't require separation then use ArcadePhysics.overlap instead. An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place, giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped. The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called. NOTE: This function is not recursive, and will not test against childre