Comments (10)
Comment by: IQAndreas
The "Graphic" you pass in should be a Class that extends Bitmap (NOT ByteArray or BitmapData).
What does your code look like?
from flixel.
There should be a more descriptive error message if the user passes in an invalid class. It might also be better to have the function return the default graphic rather than throwing an exception. I'm thinking something like:
if(!checkBitmapCache(Key))
{
var bitmap:Bitmap = new Graphic() as Bitmap;
if(bitmap == null)
{
FlxG.log("Error: " + Graphic + " must extend flash.display.Bitmap.");
return FlxG.addBitmap(FlxSprite.ImgDefault);
}
_cache[key] = bitmap.bitmapData;
}
from flixel.
There should be a more descriptive error message if the user passes in an invalid class.
Good idea!
"Error: " + Graphic + " must extend flash.display.Bitmap."
Of course, with the old code, you could pass in any class as long as it has a bitmapData
property. It didn't have to be a Bitmap
. There could be cases where this could come in handy, such as if the BitmapData
is generated rather than loaded through a Loader.
Though, in such a case, it may be better adding another method named addBitmapData
where you can explicitly pass in the BitmapData instance rather than a class.
from flixel.
I liked the warning message @moly suggested. About the the bitmapData
property @IQAndreas said, I agree it might be better idea to create a method named addBitmapData()
to explicity pass in the BitmapData
rather than a class.
from flixel.
@Dovyski I noticed you were assigned to this issue. Do you already have the code ready for this fix, or shall I write some up and add the pull request?
I think we should separate off adding the error message in this release, and adding the addBitmapData()
function to the next release.
from flixel.
I am sorry, I assigned this issue to me but stopped working when I noticed there would be some conflicts during the merge. I did nothing so far, @IQAndreas , so feel free to implement what was discussed. Bare in mind there are some pending pull requests that affect that very area of the code.
I agree with you about the error message and the new method. Leave addBitmapData()
for the next release.
from flixel.
I assigned this issue to me but stopped working when I noticed there would be some conflicts during the merge.
It seems that all pull requests that modify FlxG
have been merged by now, so I'll go ahead and add a pull request for this one.
from flixel.
I made two additional tweaks in the pull requst:
- Added
getClassName
to make the log ouput clearer - Passed along the "reverse" parameter to the "default image" sprite. I think it might make a difference?
from flixel.
The getClassName()
will be really useful.
About the "reverse", I can't tell if that makes any difference. In the context of the fix, the default image is just a "placeholder", so it's not that important to reverse it or not.
from flixel.
Resolved by 58f1e1f
from flixel.
Related Issues (20)
- Use bitwise operators for faster Math functions HOT 6
- Add FlxRandom seeded random generator HOT 13
- Add ray casting with soft shadows HOT 6
- Centralize all input handling in FlxG.input HOT 2
- Achievements in Flixel HOT 3
- FlxTween Enhancement HOT 11
- Overhaul the built-in debugger HOT 7
- Instantiable FlxColors HOT 6
- Community Notice Board HOT 3
- FlxTilemap() can't draw one-column tilemap - BitmaData exception HOT 4
- Create flixel-demos repository
- Bump version 2.58 to 3.0 HOT 2
- Add property "position" to FlxSprite HOT 4
- Implement FlxG.assets
- Dev branch lacks clear notice of Genome2d Dependency HOT 1
- Cannot get to compile against Genome2d SWC HOT 11
- FlxRandom has ASDoc validation errors HOT 3
- Context3D "Texture too big" error HOT 7
- [GPU build] calcFrame() wrong order HOT 2
- Current state of Flixel on GPU? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flixel.