quick-cocos2d-x 学习系列之十五 状态机

quick-cocos2d-x 学习系列之十五 状态机

ID:16761813

大小:19.46 KB

页数:7页

时间:2018-08-24

quick-cocos2d-x 学习系列之十五 状态机_第1页
quick-cocos2d-x 学习系列之十五 状态机_第2页
quick-cocos2d-x 学习系列之十五 状态机_第3页
quick-cocos2d-x 学习系列之十五 状态机_第4页
quick-cocos2d-x 学习系列之十五 状态机_第5页
资源描述:

《quick-cocos2d-x 学习系列之十五 状态机》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、quick-cocos2d-x学习系列之十五状态机1.代码--createFiniteStateMachineself.fsm_={}cc.GameObject.extend(self.fsm_):addComponent("components.behavior.StateMachine"):exportMethods()self.fsm_:setupState({events={{name="start",from="none",to="green"},{name="warn",from="green",to="yellow"},{name="p

2、anic",from="green",to="red"},{name="panic",from="yellow",to="red"},{name="calm",from="red",to="yellow"},{name="clear",from="red",to="green"},{name="clear",from="yellow",to="green"},},callbacks={onbeforestart=function(event)self:log("[FSM]STARTINGUP")end,onstart=function(event)s

3、elf:log("[FSM]READY")end,onbeforewarn=function(event)self:log("[FSM]STARTEVENT:warn!",true)end,onbeforepanic=function(event)self:log("[FSM]STARTEVENT:panic!",true)end,onbeforecalm=function(event)self:log("[FSM]STARTEVENT:calm!",true)end,onbeforeclear=function(event)self:log("[F

4、SM]STARTEVENT:clear!",true)end,onwarn=function(event)self:log("[FSM]FINISHEVENT:warn!")end,onpanic=function(event)self:log("[FSM]FINISHEVENT:panic!")end,oncalm=function(event)self:log("[FSM]FINISHEVENT:calm!")end,onclear=function(event)self:log("[FSM]FINISHEVENT:forthequalityof

5、reviewsandreview.Article26threview(a)theCCRAcompliance,whethercopiesofchecks;(B)whetherdoubleinvestigation;(C)submissionofprogramcompliance,investigationorexaminationofwhetherviewsareclear;(D)theborrower,guarantorloansclear!")end,onleavegreen=function(event)self:log("[FSM]LEAVE

6、STATE:green")end,onleaveyellow=function(event)self:log("[FSM]LEAVESTATE:yellow")end,onleavered=function(event)self:log("[FSM]LEAVESTATE:red")self:pending(event,3)self:performWithDelay(function()self:pending(event,2)self:performWithDelay(function()self:pending(event,1)self:perfo

7、rmWithDelay(function()self.pendingLabel_:setString("")event.transition()end,1)end,1)end,1)return"async"end,ongreen=function(event)self:log("[FSM]ENTERSTATE:green")end,onyellow=function(event)self:log("[FSM]ENTERSTATE:yellow")end,onred=function(event)self:log("[FSM]ENTERSTATE:re

8、d")end,onchangestate=function(event)self:log("[FSM]CHA

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。