-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Graphics.sprite.setAlwaysRedraw to false by default #36
Conversation
I've been struggling with this one. Using this makes things a lot simpler for the user, especially beginners who don't understand draw calls or don't want to manually manage them, but as you point out, it comes at a notable performance cost. I think you're probably right, but I'm going to have to think a bit more about it before I make this change. Mainly, I want to make sure that the docs better explain the feature. Perhaps I could surface it as an argument in |
It's definitely a good idea to offer a good explanation of the feature in the docs. Since sprites automatically handle the dirty-tracking and optimize for the least amount of draw calls necessary, the explanation should probably push users into using sprites for most things they want to render this way we can avoid them having to worry about this. Instead of putting in Noble.config({
setAlwaysRedraw = true,
showFPS = true
})
Noble.new(...) This could serve for future more advanced configuration, for instance if you want to configure the threshold used to determine whether a button is held or not (say instead of 3 frames you want a threshold of 5 frames), or other things I can't think of at the moment. |
Yeah, I like that solution. I think the way I'd do it is letting users pass a config table object as an optional argument in |
Graphics.sprite.setAlwaysRedraw to false by default
I've gone in and updated Noble.lua to add a configuration API, which allows user to set these values:
I did leave |
I'm very happy that your PR inspired this change, btw! |
In Noble.lua at line 91 you set
Graphics.sprite.setAlwaysRedraw(true)
when the SDK Documentation specifies that it can be faster only in very specific circumstances (namely when you have a ton of sprites moving at once.I am not sure if there were any reasons why you opted-in, but I think it would be wiser to have this set to false by default, so that all the simpler projects that rely on NobleEngine can benefit from the battery and performance improvements of fewer draw calls, and only when they reach this specific bottleneck can they opt-in to this behaviour, as it is with the default SDK.