[SOLVED]
Hi All,
Been away quite a while and thought I would come back to AppGameKit, starting with a simple brick breaker game to get savvy once again.
The bat, ball and bricks are physics sprites and collisions occur between them all (ball hits and bounces as it should).
However, although the collisions are occurring, GetPhysicsCollision(Ball, Bricks[x,y]) correctly detects there has been a collision, yet GetPhysicsCollision(Ball, Bat) does not register the collision?
See some code below:
//1: Ball Creation
ball = CreateSprite(0)
SetSpriteSize (Ball,1,-1)
SetSpriteShape(Ball, 1)
SetSpritephysicson(Ball, 2)
SetSpritePhysicsFriction(Ball, 0.0)
SetSpritePhysicsRestitution(Ball, 1)
SetSpritePhysicsMass(Ball, 0.01)
SetSpritePhysicsIsBullet(Ball, 1)
SetSpritePhysicsCanRotate(Ball, 0)
SetSpritePosition(Ball, 50,80)
SetSpriteColor(Ball, 0,255,0,255)
SetPhysicsGravity(0.0,0.0)
SetSpritePhysicsVelocity(Ball, 30.0, 40.0)
//2: Bat Creation
Plr = CreateSprite(0)
SetSpritesize(Plr, 10.0, 5.0)
SetSpriteColor(Plr, 255,0,255,255)
SetSpritePhysicsOn(Plr, 3)
SetSpriteShape(Plr, 2)
SetSpritePosition(Plr, 50.0, 90.0)
SetSpritePhysicsMass(Plr,1.0)
SetSpritePhysicsIsBullet(Plr,1)
//3: Ball-Brick Collision (Detects Correctly)
for Rows = 0 to NUMBRICKROWS - 1
For Cols = 0 to NUMBRICKCOLS - 1
if GetPhysicsCollision(Ball, Bricks[Cols,Rows].Spr)
PlaySound(BallSnd)
if Bricks[Cols,Rows].bParticleOn = 0
Bricks[Cols,Rows].bParticleOn = 1
ResetParticleCount(Bricks[Cols,Rows].iParticle)
if Bricks[Cols,Rows].iHitCount < Bricks[Cols,Rows].iHitsToKill
inc Bricks[Cols,Rows].iHitCount, 1
Else
SetSpriteVisible(Bricks[Cols,Rows].Spr, 0)
SetSpriteActive(Bricks[Cols,Rows].Spr, 0)
SetParticlesActive(Bricks[Cols,Rows].iParticle, 0)
SetSpritePhysicsoff(Bricks[Cols,Rows].Spr)
Endif
Endif
Endif
if GetParticlesMaxReached(Bricks[Cols,Rows].iParticle) = 1
Bricks[Cols,Rows].bParticleOn = 0
Endif
Next Cols
Next Rows
//4: Ball-Bat Collision - Never Detects
if GetPhysicsCollision(Plr, Ball)
PlaySound(BallHitBat)
Print("HIT")
Endif
I have tried changing sprite groups to no avail.
Feeling kinda dumb here, so any help much appreciated!
I control all the juicy in here!