Author Topic: [SOLVED]Temporary hitbox implementation issue  (Read 967 times)

adamSrgnt

  • Member
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
[SOLVED]Temporary hitbox implementation issue
« on: Tue, Oct 23, 2012 »
I'm currently making a game where the character swings at a ball.  The swinging is happening away from the body of the character, so I'm trying to make a hitbox that appears during the swing animation for overlap calculations.  For the hitbox, I am using an FlxRect.
My problem is that when I try to call overlap to check the ball and hitbox, I get this error:
Code: [Select]
FlxG.overlap(swingHitbox, ball, hitBall);

Error: Implicit coercion of a value of type org.flixel:FlxRect to an unrelated type org.flixel:FlxBasic.

What is wrong, and is there a better way I should be approaching this?
« Last Edit: Tue, Oct 23, 2012 by adamSrgnt »

wg/funstorm

  • Global Moderator
  • Key Contributor
  • *****
  • Posts: 596
  • Karma: +0/-0
    • View Profile
    • Funstorm
Re: Temporary hitbox implementation issue
« Reply #1 on: Tue, Oct 23, 2012 »
Well like you say, overlap expects an object that is of type FlxBasic, but FlxRect does not extend FlxBasic. So I think the easiest solution would be to give it something that extends FlxBasic, for example an invisible FlxSprite or FlxObject with the width & height of the hitbox.

adamSrgnt

  • Member
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Re: Temporary hitbox implementation issue
« Reply #2 on: Tue, Oct 23, 2012 »
FlxObject got rid of the error.  Stupid question I suppose.  I had seen examples using FlxRect when I searched the forum so I figured that was the way to go.

I am having an issue now with it not detecting overlap or not doing what intended, but I'm checking my code to see if the hitbox Object is the source of the problem.
« Last Edit: Tue, Oct 23, 2012 by adamSrgnt »

adamSrgnt

  • Member
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Re: Temporary hitbox implementation issue
« Reply #3 on: Tue, Oct 23, 2012 »
Found a new issue somewhat related but I'm going to mark this solved and maybe start a new topic.