Author Topic: EZPlatformer - Access of possibly undefined property onFloor  (Read 1394 times)

bakana

  • Member
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
    • gildedgreen
Hey, so yesterday I downloaded Flixel, and worked my way through a few tutorials, including the EZPlatformer one. I added some sounds and animations, and really felt like I was figuring this out.
Today, I visited the site, and saw it was an all new page, and there was a new update to flixel, so I downloaded version 2.5 (and too hastily replaced the old version I had).
Now the program that ran so well yesterday is coughing up major errors, but I feel like working through them will help me get up to speed with this new version.

The first big error I have is from the code for making the player jump:

Code: [Select]
if(FlxG.keys.SPACE && player.onFloor)
{
player.velocity.y = -player.maxVelocity.y / 2;
}

Which yields this error:
Quote
..\PlayState.as(170): col: 30 Error: Access of possibly undefined property onFloor through a reference with static type org.flixel:FlxSprite.

Now, from my investigating, the proper way to update this code would be to do this:

Code: [Select]
if(FlxG.keys.SPACE && player.isTouching(FLOOR))
{
player.velocity.y = -player.maxVelocity.y / 2;
}

However, that just generates THIS error:
Quote
..\PlayState.as(170): col: 41 Error: Access of undefined property FLOOR.

Any suggestions would be much appreciated.  I felt so sure-footed yesterday, and suddenly feel totally lost again.  Hopefully sorting this out on the forum will help me more independently resolve the other compiling errors I'm getting.

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
very close!  just use FlxObject.FLOOR, like it says on the wiki and in the source code on github :)

bakana

  • Member
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
    • gildedgreen
Thanks so much for the quick and helpful reply, Adam!  Also, thanks for pointing out github, it made it very easy to navigate the files, and I managed to update and change the other error-producing code (mostly collision stuff that had moved from FlxU to FlxG, changing FlxSprite.RIGHT/LEFT to FlxObject.RIGHT/LEFT and other little things like bgColor fiddling), and get the program working as it was with the old flixel! Digging around in the classes also helped me to get a bit of a handle on the new version.

One thing I wasn't sure of, though (and I just cheaply 'fixed' it by commenting it out):  My old code had a preloader which used the 'FlxPreloader' class. On compiling, it said that this class was not defined, and, truly, there is no longer a FlxPreloader.as file... But the class is still in the API documentation - should it be?  What class should we use now for managing preloaders?

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
It's just not in the root package anymore, so you have to add import org.flixel.system.preloader; or whatever to the top of the file to make sure it can find the class