Jump to content
  • Advertisement
Sign in to follow this  
lance3g

The state machine in Singles2

This topic is 4081 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:
beginStateMachine()

	onEnter(function(msg)
	
		if this.animName then
			-- scene graph animation
			this.startAnimation(this.animName);
		end
		
		if this.hasMaterial("glowMat") then
			-- texture animation
			sendMsgThis("startAnim");
		end
	
	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 )
			
endStateMachine()
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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!