
上QQ阅读APP看书,第一时间看更新
Time for action — modifying the rocket class
To modify the rocket
class, we will follow the ensuing steps:
- Open the
rocketClass.monkey
file. - Modify the
Update
method and add aCreateExplosion
call there. The parameters are the current X and Y positions of the rocket.If cy < ty Then CreateExplosion(Self.cx, Selfish) rockets.Remove(Self) Endif
- Save the file.
What just happened?
We have modified the rocket
class to create a new explosion once the rocket reaches its target position.