Error: Type not found

196 views
Skip to first unread message

Egor Vasilyev

unread,
May 29, 2015, 7:16:49 PM5/29/15
to haxef...@googlegroups.com
Hi! I try to create auto-scrolling background with FlxBackdrop:

package;

import flixel.FlxState;
import flixel.text.FlxText;
import flixel.addons.display.FlxBackdrop;
class PlayState extends FlxState
{
   
var backgroundMoving:FlxBackdrop = new FlxBackdrop(AssetPaths.background0__png, 1, 0, true, false);

   override public function create():Void
   
{
      add
(new FlxText(0, 0, -1, "Hello, world!"));
      add
(backgroundMoving);
     
super.create();
   
}
   

   override public function destroy():Void
   
{
     
super.destroy();
   
}

   override public function update():Void
   
{
     
super.update();
   
}  
}

But it failed with error:

Error:(5, 7) Type not found : flixel.addons.display.FlxBackdrop.

What's wrong?


Gama11

unread,
May 30, 2015, 3:15:50 AM5/30/15
to haxef...@googlegroups.com, e.va...@nexters.com
You likely didn't include the flixel-addons haxelib in your Project.xml.

Also, you shouldn't initialize class members that are FlxSprites / FlxTexts etc at their declaration, that can lead to issues - everything should happen in create(). The problem is that that code is moved into the constructor, and Flixel destroys() all objects right before calling create() to clean up after state switches - after the constructor is called.

Egor Vasilyev

unread,
May 30, 2015, 12:38:09 PM5/30/15
to haxef...@googlegroups.com
Thanx, now it work, but FPS goes down, when i move mouse.

class PlayState extends FlxState
{
   
var backgroundMoving:FlxBackdrop;

   override public function create():Void
   
{

     
add(backgroundMoving = new FlxBackdrop(AssetPaths.background0__png, 1, 1, true, false));
      backgroundMoving.velocity.set(-100, 0);
      super.create();
   }



суббота, 30 мая 2015 г., 2:16:49 UTC+3 пользователь Egor Vasilyev написал:

SruloArt

unread,
May 31, 2015, 4:50:26 AM5/31/15
to haxef...@googlegroups.com
The Flash standalone player is the cause. It shouldn't be very noticeable on the browser's plugin version / other targets like neko.
Reply all
Reply to author
Forward
0 new messages