0

I downloaded flixel and photonstorm in order to their perfect collision stuff (FlxCollision); in my root folder I have the flixel org folder and inside org/plugin I extracted photostorm as instructed at their site; I'm importing it here:

import org.flixel.*;
import org.flixel.plugin.photonstorm.*;

The problem is that when I call the function that will detect the collision (if statement to be precise) I get this error:

if (FlxCollision.pixelPerfectCheck (ball, goalkeeper)){
      ball.y=portero.x-ball.height- ball.width;
     trace ("Tomela");

}

Scene 1, Layer 'action', Frame 1, Line 72   1067: Implicit coercion of a value of type flash.display:MovieClip to an unrelated type org.flixel:FlxSprite.

I'll really appreciate if you guide me a little bit, I'm using Flash Professional CS5.

i'llbdevsomeday
  • 151
  • 1
  • 4
  • 11
  • 1
    The error sounds pretty straightforward, the function requires a Flixel object `FlxSprite` and you are instead passing in a native flash object `MovieClip` – TheZ Aug 17 '12 at 17:28

1 Answers1

3

FlxCollision.pixelPerfectCheck takes FlxSprite objects as parameters. You are passing in MovieClips as your arguments (either one or both), hence the error.

Either change your objects to be FlxSprites or use a pixel perfect collision library that works on MovieClips.

Pixel Elephant
  • 20,649
  • 9
  • 66
  • 83
  • Thanks a lot guys, I knew Flixel couldn't be that easy for a newbie, I was so happy...Pixel Elephant, do you know any library that supports MovieClips? I´ll really appreciate it man! – i'llbdevsomeday Aug 17 '12 at 17:52
  • 1
    @i'llbdevsomeday I have used Corey O'Neils CDK in the past: http://code.google.com/p/collisiondetectionkit/ It works with any DisplayObject – Pixel Elephant Aug 17 '12 at 18:14