• Advertisement
Sign in to follow this  

The state machine in Singles2

This topic is 3959 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am learning lua recently and find Singles2 is a good source. All of the state machine is written in lua:

		if this.animName then
			-- scene graph animation
		if this.hasMaterial("glowMat") then
			-- texture animation
	end )
	onMsg("startAnim", function(msg)
		preloadTextures(this, {"Glitzer_000", "Glitzer_001", "Glitzer_002", "Glitzer_003"});
		startAnim({"Glitzer_000", "Glitzer_001", "Glitzer_002", "Glitzer_003"}, 0.1);
	end )
	onMsg("showPic", function(msg)
		replaceTexture("glowMat", msg.data);
	end )
The syntax is like an article in Game programming gems 1. But in that article it is written in C. So I am wondering how Single2 utilize this lua code? Maybe they write some cpp functions like beginStateMachine() and onMsg()? And generate a cpp FSM class using the lua code?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement