pulp-to-lua icon indicating copy to clipboard operation
pulp-to-lua copied to clipboard

Playing an animation never ends

Open BoldBigflank opened this issue 3 years ago • 2 comments

I believe this is what is happening. I have this code in the player script that is called when an enemy is able to attack the player.

on playerHit do
	ignore
	gameIgnored = 1
	playerFrame += 1
	sound "death"
	play "die" then
		if playerFrame>3 then
			fin "Game over"
		else
			tell 12,12 to
				swap "white"
			end
			goto 12,12
			play "player"
			tell event.player to
				frame playerFrame
			end
			gameIgnored = 0
			listen
		end
	end
end

In the Pulp browser simulator, it does what I expect, which is play the 6 or so frames for the animation, then do the rest of the code to move the player back to the start position. In the compiled Simulator though, the animation is played over and over, and never moves on. The rest of the game is continuing at the same time.

BoldBigflank avatar May 16 '22 03:05 BoldBigflank

For more information, I was able to get around the issue by changing the code to this


on playerHit do
	ignore
	gameIgnored = 1
	playerFrame += 1
	sound "death"
	play "die"
	wait 0.7 then
		if playerFrame>3 then
			fin "Game over"
		else
			tell 12,12 to
				swap "white"
			end
			goto 12,12
			play "player"
			tell event.player to
				frame playerFrame
			end
			gameIgnored = 0
			listen
		end
	end
end

The change was just calling play in one line, then calling wait 0.7 then to properly delay the rest of the code.

BoldBigflank avatar May 16 '22 03:05 BoldBigflank

If you have time, could you please upload a pulp .json project which has this error? Or you can send me one on Discord (NaOH#1432).

nstbayless avatar May 21 '22 20:05 nstbayless