greencoder Posted March 30, 2018 Share Posted March 30, 2018 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); }, }); Quote Link to comment Share on other sites More sharing options...
enpu Posted April 3, 2018 Share Posted April 3, 2018 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? Quote Link to comment Share on other sites More sharing options...
greencoder Posted April 4, 2018 Author Share Posted April 4, 2018 Sorry forget about the topic I asked. I was thinking of an OnCollision callback for each entity against any object and not just one on one hitTest. I managed to get a workaround without that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.