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

Offer non-blocking animation APIs #327

Closed
nighca opened this issue Sep 9, 2024 · 4 comments
Closed

Offer non-blocking animation APIs #327

nighca opened this issue Sep 9, 2024 · 4 comments

Comments

@nighca
Copy link
Collaborator

nighca commented Sep 9, 2024

For now we allow the developers to choose blocking or non-blocking APIs when doing time-consuming operations like broadcasting messages or playing audios:

func (p *Game) Broadcast__0(msg string) // non-blocking
func (p *Game) Broadcast__1(msg string, wait bool) // `wait: true` means blocking
func (p *Game) Broadcast__2(msg string, data interface{}, wait bool) // `wait: true` means blocking

func (p *Game) Play__0(media Sound) // non-blocking
func (p *Game) Play__1(media Sound, wait bool) // `wait: true` means blocking
func (p *Game) Play__2(media Sound, action *PlayOptions)
func (p *Game) Play__3(mediaName string) // non-blocking
func (p *Game) Play__4(mediaName string, wait bool) // `wait: true` means blocking
func (p *Game) Play__5(mediaName string, action *PlayOptions)

While there's no non-blocking choice for animation-related APIs, which includes Animate, Glide, Step, Turn & TurnTo.

Non-blocking animation call is important in many cases, for example, when we are controlling more than one sprites together and we want them to animate simultaneously:

// For now there's no easy way to let A & B glide simultaneously
spriteA.glide 0, 0, 1
spriteB.glide 100, 100, 1

This is proposal to add non-blocking version for these APIs:

Animate

// existed (blocking):
func (p *Sprite) Animate(name string)
// new added (non-blocking with `wait: false`):
func (p *Sprite) Animate(name string, wait bool)

Glide

// existed (blocking):
func (p *Sprite) Glide(x, y float64, secs float64)
func (p *Sprite) Glide(obj interface{}, secs float64)
// new added (non-blocking with `wait: false`):
func (p *Sprite) Glide(x, y float64, secs float64, wait bool)
func (p *Sprite) Glide(obj interface{}, secs float64, wait bool)

Step

// existed (blocking):
func (p *Sprite) Step(step float64)
func (p *Sprite) Step(step int)
func (p *Sprite) Step(step float64, animname string)
// new added (non-blocking with `wait: false`):
func (p *Sprite) Step(step float64, wait bool)
func (p *Sprite) Step(step int, wait bool)
func (p *Sprite) Step(step float64, animname string, wait bool)

Turn

// existed (blocking):
func (p *Sprite) Turn(val interface{})
// new added (non-blocking with `wait: false`):
func (p *Sprite) Turn(val interface{}, wait bool)

TurnTo

// existed (blocking):
func (p *Sprite) TurnTo(obj interface{})
// new added (non-blocking with `wait: false`):
func (p *Sprite) TurnTo(obj interface{}, wait bool)
@nighca nighca changed the title Support non-blocking animation APIs Offer non-blocking animation APIs Sep 10, 2024
@nighca

This comment was marked as outdated.

@nighca

This comment was marked as outdated.

@nighca
Copy link
Collaborator Author

nighca commented Sep 23, 2024

@nighca
Copy link
Collaborator Author

nighca commented Sep 27, 2024

Follow up on #337.

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

No branches or pull requests

1 participant