I've got a game in development called "Fling". Here's a screenshot.
Basically, I'm trying to get a ball shot up in between that gap. However, since these sprites are squares instead of circles, I'm trying to utilize
alphaCollision to detect if the circles are overlapping or not.
Specifically, I'm trying to figure out how to utilize
alphaCollision in tandem with
moveWithCollisions. Here is a snippet of code demonstrating what I'm trying to do:
function FlyingBall:update() self.xCoord = self.xCoord + self.xVelocity self.yCoord = self.yCoord + self.yVelocity local actualX, actualY, collisions, _ = self:moveWithCollisions(self.xCoord, self.yCoord) for i = 1, #collisions do local collision = collisions[i] if(collision.sprite:alphaCollision(collision.other)) then print("You are _actually_ colliding right now") local newBallXIndex, newBallYIndex = calculateIndices(actualX, actualY, 'ball') self:remove() Ball(newBallXIndex, newBallYIndex, ballSelector.patternName) end end end
I never get inside the
I think I'm doing something fundamentally wrong, but the docs don't provide any code examples that might help guide me to use this function.
Any help is much appreciated! Thanks in advance.