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

Die behavior with animation #315

Closed
nighca opened this issue Aug 20, 2024 · 1 comment
Closed

Die behavior with animation #315

nighca opened this issue Aug 20, 2024 · 1 comment

Comments

@nighca
Copy link
Collaborator

nighca commented Aug 20, 2024

As mentioned in #314 , if we call die of cloned sprite, its scripts / coroutines will be stopped.

For sprite with code below:

onCloned => {
	for {
		wait 0.1
		println "im alive"
	}
}

onCloned => {
	show
	wait 1
	println "call die"
	die
}

onStart => {
	clone
}

We'll get output like this:

✗ gop run .
im alive
im alive
im alive
im alive
im alive
im alive
im alive
im alive
im alive
call die

But if there's a dying animation, which requires some time to play, we'll get output like this:

✗ gop run .
im alive
im alive
im alive
im alive
im alive
im alive
im alive
im alive
im alive
call die
im alive
im alive
im alive
im alive
im alive
im alive
im alive
im alive

Game developers may perform more complex actions than just println "im alive", potentially affecting overall game behavior. They will have to maintain their own isDead state to avoid mistakes:

var isDead bool

onCloned => {
	for {
		wait 0.1
		if isDead {
			break
		}
		println "im alive"
	}
}

onCloned => {
	show
	wait 1
	println "call die"
	isDead = true
	die
}

onStart => {
	clone
}

It is advisable to adjust SPX behavior to lessen the burden on game developers. We could stop scripts / coroutines when die is called, rather than waiting for the animation to finish.

Please share your ideas here, @xushiwei @JiepengTan.

@nighca
Copy link
Collaborator Author

nighca commented Sep 20, 2024

closed by #333

@nighca nighca closed this as completed Sep 20, 2024
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