loadGraphic failing in Neko and Windows

54 views
Skip to first unread message

Ariel Cid

unread,
Dec 18, 2015, 8:08:17 PM12/18/15
to HaxeFlixel


Hi there!

I'm having some issues with FlxSprite.loadGraphic when I try to load a bitmapData in Neko and Windows targets. The code that is giving me trouble is this one (which is in the update function, after creating and initializing both FlxSprites):

playerFrame.loadGraphic(player.framePixels);

And the runtime error is this one:

Invalid field access : bitmap
Called from flixel.FlxSprite::loadGraphic line 311
Called from states.PlayState::update line 91
Called from flixel.FlxState::tryUpdate line 155
Called from flixel.FlxGame::update line 700
Called from flixel.FlxGame::step line 648
Called from flixel.FlxGame::onEnterFrame line 493

If someone could tell me what am I doing wrong, I would really appreciate it.


Thanks in advance!

Gama11

unread,
Dec 19, 2015, 9:13:39 AM12/19/15
to HaxeFlixel
framePixels is by default unused (null) on native targets - invalid field access is basically a null reference exception. If loadGraphicFromSprite() or sprite.pixels.

Also, you're calling loadGraphic() every frame in update()?

Ariel Cid

unread,
Dec 20, 2015, 12:40:51 PM12/20/15
to HaxeFlixel
I'm calling loadGraphic() every frame in update() because I'm using a dynamic alpha mask (it uses the current animation frame from the sprite).



So, if I use sprite.pixels, it doesn't get the current frame but the whole image (a huge spritesheet). Is there a better way to do this?

Gama11

unread,
Dec 20, 2015, 12:45:06 PM12/20/15
to HaxeFlixel
Try calling getFlxFrameBitmapData() before using framePixels to initialize it.

Ariel Cid

unread,
Dec 20, 2015, 12:47:01 PM12/20/15
to HaxeFlixel
It worked wonderfully, thanks a lot! <3
Reply all
Reply to author
Forward
0 new messages