All good things must come to an end and if you aren't careful, that will include your ship. We already saw that we checked whether the ship health was
0 or less in the
TakeDamage function. If it was, we made a call to
DestroyShip, so let's create that function now, as given in the following code:
-- Get the scene and user objects local hScene = application.getCurrentUserScene ( ) local hUser = application.getCurrentUser ( ) -- Create an explosion based on the smaller collision explosions local hExplosion = scene.createRuntimeObject ( hScene, "ExplosionHelper" ) -- Move the explosion, scale it up and trigger the explosion object.matchTranslation ( hExplosion, this.hShip ( ), object.kGlobalSpace ) sfx.setParticleEmitterUniformScaleAt ( ...