Jump to content

Destroy() vs Kill()


tjs_uk
 Share

Recommended Posts

Hi

 

I am currently writing a game, but I have noticed that it is pushing the processor to the max.  Previous discussions would suggest that it can be a problem with the browser, however I think I have too much going on at the same time.  I have created a version of Asteroids, so as you can imagine there a lot of collisions, which from my understanding can cause the processor to work hard.

 

My question is, I am currently using Destroy() when the asteroids are hit, would I be better off using Kill() instead?  What would also be the most efficient way to recycle the asteroids?

 

collisionHandler: function (bullet, asteroid) {

 
    //get asteroid.kill type and position
    var asteroidKey = asteroid.key.toString();
    var asteroidX = asteroid.position.x;
    var asteroidY = asteroid.position.y;
    
    //  When a bullet hits an asteroid we kill them both
    bullet.kill();
    asteroid.destroy();
    ...
 
The game can be played at http://tjs_uk.bitbucket.org
 
I intend to reduce the amount of code, now that it is working (and I have a better understanding of the Phaser... sort of??)
 
Thanks in advance.
 
Trev.  :)
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...