Skip to content

Commit

Permalink
Fix shot detection code in case of flipped sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
wongjustin99 committed Nov 21, 2013
1 parent 9e4f585 commit 5a0bb1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Assets/Scripts/Pages/Gamepage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void HandleUpdate()
Rect enemyBounds = enemy.GetTextureRectRelativeToContainer();

// check if the enemy contains the player shot's position
if(enemyBounds.Contains(shotPos))
if(enemyBounds.CheckIntersectComplex( new Rect(shotPos.x, shotPos.y, 1.0f, 1.0f) ) )
{
//bullet has hit so make enemy take damage
//takeDamage(damage) returns true if unit has died
Expand All @@ -193,7 +193,7 @@ public void HandleUpdate()

Rect playerBounds = _player.GetTextureRectRelativeToContainer();

if(playerBounds.Contains(shotPos))
if(playerBounds.CheckIntersectComplex( new Rect(shotPos.x, shotPos.y, 1.0f, 1.0f) ) )
{
ShotManager.removeShot(_shot);
_player.playerDeath();
Expand Down

0 comments on commit 5a0bb1f

Please sign in to comment.