Stamp applies to all sprites with same bitmap on Windows target

31 views
Skip to first unread message

Vasco

unread,
Jan 13, 2016, 7:03:13 PM1/13/16
to HaxeFlixel
For example,

sprite1 = new FlxSprite(0, 0, "assets/images/test.png");
sprite2 = new FlxSprite(0, 0, "assets/images/test.png");  // uses same image as sprite1

sprite1.stamp(new FlxSprite(0, 0, "assets/images/stamp.png"), 0, 0);  // only sprite1 will be affected on Flash target, but both sprite1 and sprite2 will be stamped on Windows target

Is this a bug or am I doing something wrong? I am using the lastest stable Flixel build, version 3.3.12.

Vasco

unread,
Jan 13, 2016, 10:01:02 PM1/13/16
to haxef...@googlegroups.com
I think I found the solution to the problem. I can call loadGraphic() with the "Unique" parameter to true, this will create a new instance in the graphics cache for each sprite. This solves the problem, although it is kind of wasteful in terms of memory, since I will have a lot of these sprites, many with the same stamped image. But hopefully I will think of a way around that.

EDIT: Ok, I see now that there is also a key:String parameter, to identify the instance. Awesome, problem solved!

Jeru Sanders

unread,
Jan 14, 2016, 3:14:15 PM1/14/16
to HaxeFlixel
Why do the graphics need to be stamped together, could you not make a single stamp sprite or anything?

Vasco

unread,
Jan 14, 2016, 4:45:38 PM1/14/16
to HaxeFlixel
Well, in my case there are over 200 possible sprite combinations, so it's easier and more efficient to create each sprite by stamping the different parts when I need them.
Reply all
Reply to author
Forward
0 new messages