Skip to content
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

Add support for debugDraw in scenes #53

Open
GammaGames opened this issue Jul 16, 2023 · 1 comment · May be fixed by #54
Open

Add support for debugDraw in scenes #53

GammaGames opened this issue Jul 16, 2023 · 1 comment · May be fixed by #54
Labels
enhancement New feature or request

Comments

@GammaGames
Copy link
Contributor

GammaGames commented Jul 16, 2023

Describe the feature
It would be nice if I could set a function's debug draw function similar to scene:drawBackground. The color could also be set like scene.debugColor, (and then pd.setDebugDrawColor(r, g, b, a)) so it's like background.

Describe alternatives you've considered
I could add it my own, and rn I'm going to do it by manually adding it in my scene:enter and scene:exit for my base scene

What problems would this solve or help prevent, if any
It would be cool, and I'm adding a debug system menu toggle that I want to use. Having a

Additional context
Here's what I'm currently doing in my BaseScene.lua:

BaseScene.debugColor = {1, 0, 0, 0.5}

function BaseScene:enter()
    BaseScene.super.enter(self)

    pd.setDebugDrawColor(table.unpack(self.debugColor))
    function playdate.debugDraw()
        self:drawDebug()
    end
end

function BaseScene:exit()
    BaseScene.super.exit(self)
    
    function playdate.debugDraw() end
end

function BaseScene:drawDebug() end
@GammaGames GammaGames added the enhancement New feature or request label Jul 16, 2023
@GammaGames
Copy link
Contributor Author

Hmm, maybe a helper function to enable instead of always forcing it on. Idk how it affects performance. Now my script looks like:

BaseScene.debugColor = {1, 0, 0, 0.5}

function BaseScene:enter()
    BaseScene.super.enter(self)
    pd.setDebugDrawColor(table.unpack(self.debugColor))
end

function BaseScene:exit()
    BaseScene.super.exit(self)
    self:disableDebug()
end

function BaseScene:enableDebug()
    function pd.debugDraw()
        self:drawDebug()
    end
end

function BaseScene:disableDebug()
    function pd.debugDraw() end
end

function BaseScene:drawDebug() end

@GammaGames GammaGames linked a pull request Jul 22, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant