Skip to content

Conversation

@geekrelief
Copy link
Contributor

So we can handle signals with an {.async.} proc like this:

...
import asynchdispatch

gdobj SpriteComp of Sprite:

  signal bsclick(button_idx:int, shape_idx:int)

  method ready() =
    ...
    registerFrameCallback(
      proc() =
        if hasPendingOperations():
          poll(0)
    )
    asyncCheck self.fireTimer()
    self.emit_signal("bsclick", 1.toVariant, 0.toVariant)

  proc fireTimer() {.async.} =
    await on_signal(self.get_tree().createTimer(1), "timeout")
    print "timeout sceneTree"

    var vals = await on_signal(self, "bsclick", tuple[button_idx:int, shape_idx:int])
    print &"bsclick {vals.button_idx = } {vals.shape_idx = }"

cleaned up godotmacros imports
updated code sample at bottom of godotmacros.nim
@arunvickram
Copy link
Contributor

Do signals work with either camelCase or snake_case? Or does it only work with snake_case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants