-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement wasDestroyed
check on FlxGraphic
#2968
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -635,6 +635,11 @@ class FlxCamera extends FlxBasic | |
itemToReturn = new FlxDrawItem(); | ||
} | ||
|
||
if (graphic.wasDestroyed) { | ||
// Throw an exception here, because throwing in `FlxDrawQuadsItem.render()` is not helpful. | ||
throw 'Attempted to queue invalid FlxDrawItem, did you dispose of a cached sprite?'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i want to avoid the word dispose, and just use the word "destroy" consistently. since that's the function they are likely calling |
||
} | ||
|
||
itemToReturn.graphics = graphic; | ||
itemToReturn.antialiasing = smooth; | ||
itemToReturn.colored = colored; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -343,6 +343,16 @@ class FlxGraphic implements IFlxDestroyable | |
*/ | ||
public var atlasFrames(get, never):FlxAtlasFrames; | ||
|
||
/** | ||
* This value is `true` if this graphic has been disposed. | ||
* Attempting to render a disposed graphic will cause an error. | ||
*/ | ||
public var wasDestroyed(get, never):Bool; | ||
|
||
function get_wasDestroyed():Bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no cuddling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also let's inline this |
||
return shader == null; | ||
} | ||
|
||
/** | ||
* Storage for all available frame collection of all types for this graphic object. | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,12 @@ class FlxDrawQuadsItem extends FlxDrawBaseItem<FlxDrawQuadsItem> | |
return; | ||
|
||
var shader = shader != null ? shader : graphics.shader; | ||
|
||
if (shader == null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no cuddling |
||
// If this gets called, the check for `graphic.wasDestroyed` in FlxCamera failed. | ||
throw 'Attempted to render invalid FlxDrawItem, did you dispose of a cached sprite?'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the word "destroy" |
||
} | ||
|
||
shader.bitmap.input = graphics.bitmap; | ||
shader.bitmap.filter = (camera.antialiasing || antialiasing) ? LINEAR : NEAREST; | ||
shader.alpha.value = alphas; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no cuddling