Jump to content

HitTest As A Trigger


greencoder
 Share

Recommended Posts

I have multiple moving objects in the sceen, which I am planning to generate procedurally and would like my bullet class to detect a collision when it passes through the objects. I would like to have an opinion about how the detection should go about. It going to be tedious if I hitTest with bullet all the bird objects in the scene to find whether the bullet is colliding or not. Is there an option for Bullet class/object to act like a trigger?

game.createClass('bullet', {
    
    init: function(aStage) {
        this.mSprite = new game.Sprite('Bullet_Tex.png');
        this.mSprite.addTo(aStage);
    },
});

game.createClass('bird', {
    
    init: function(aStage) {
        this.mSprite = new game.Sprite('Bird_Tex.png');
        this.mSprite.addTo(aStage);
    },
});
Link to comment
Share on other sites

I'm not entirely sure what you mean by "act like a trigger". What does that technically mean?

If you want to test if your bullet hits any of your birds, then you do need to hit test against every bird, can't really think another way. How is that tedious?

 

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...