1 decade ago by GarryS
I am having an issue with the following code:
update: function() {
var ball = ig.game.getEntitiesByType(EntityBall);
if (this.touches(ball[0])) {
do stuff
}
}
This code is for a block entity defined in blocks.js. The problem is that it works only some of the time. Specifically, I have 1 EntityBall flying around and 22 EntityBlocks on the board. I use this to test if the ball touches the block and then kill it, etc. It seems that every time I reload the level about 3 or so of the blocks are not affected by the ball touching it. Is there a better way to test for this collision?
update: function() {
var ball = ig.game.getEntitiesByType(EntityBall);
if (this.touches(ball[0])) {
do stuff
}
}
This code is for a block entity defined in blocks.js. The problem is that it works only some of the time. Specifically, I have 1 EntityBall flying around and 22 EntityBlocks on the board. I use this to test if the ball touches the block and then kill it, etc. It seems that every time I reload the level about 3 or so of the blocks are not affected by the ball touching it. Is there a better way to test for this collision?