I attempted to add a sprite into my state:
package;
import flixel.FlxSprite;
import flixel.FlxState;
class PlayState extends FlxState
{
override public function create():Void
{
var spr:FlxSprite = new FlxSprite();
spr.loadGraphic(AssetPaths.testSprite__png);
add(spr);
super.create();
}
override public function update(elapsed:Float):Void
{
super.update(elapsed);
}
}
And this is my testSprite.png
:(testSprite.png
was created by mspaint
and saved as a PNG.)

But when I was running my project, I saw nothing on the screen. So I traced my spr.graphic
:
PlayState.hx:16: { assetsKey => assets/images/testSprite.png, width => 0, _useCount => 1, frameCollectionTypes => [], frameCollections => { root => { left => null, right => null, _height => 1, key => IMAGE, value => [(frames: [(name: null)] | type: IMAGE)] } }, unique => false, _imageFrame => (frames: [(name: null)] | type: IMAGE), _destroyOnNoUse => true, bitmap => { __handle => null, __transparent => true }, isDumped => false, key => assets/images/testSprite.png, height => 0, persist => false }
width
and height
were unexpected 0 ! I tried to indicate width
and height
manually but no helps.
So what's wrong?
Addition
I try to add another one sprite in the same way, but it works.
The another sprite(ship.png
from ScaleMode Example):

Now that this one could be added , then why my sprite not ?
Another interesting phenomena
Since testSprite.png
was failed to add, other sprites could not name after it or it will not be able to be added in, either.
For example
testSprite.png
fails and I renamed it as obsoleted.png
.Then I rename the ship.png
, which was successfully added previously, as testSprite.png
and interestingly, the new testSprite.png
could not be added in for now till it's renamed as other names but testSprite.png
.
Now I delete the current obsoleted.png
and renamed testSprite.png
(originally is ship.png
) as obsoleted.png
, and it fails again!
Is that an issue?