easyx_framework V1.0.0
基于easyx的c++游戏框架
 
载入中...
搜索中...
未找到
F:/vc/project/esayx_framewoek/esayx_framewoek/zomblestatus.h
浏览该文件的文档.
1#pragma once
2#include"FSM.h"
3#include"Collider.h"
4#include"Sprite.h"
5//#include"AudioManager.h"
6
7class walkstatus :public FSMItems
8{
9public:
10 walkstatus(int _status, FSMItems* _parent = nullptr, int _level = 0)
11 :FSMItems(_status, _parent, _level)
12 {
13
14 enter.Bind([this]() {
15 ani->SetNode("walk"); ani->SetCalled(true);
16 std::cout << "enter walk status" << std::endl;
17
18 //col->OnComponentBeginOverlap.Push([this](Collider* overlapcomponentself, Collider* othercomponent, Object* otherobject)
19 // {fsm->TransitionState("stand"); });
20 });
21 act.Bind([this]() {
22 /*fsm->GetOwner()->AddPosition({ -fsm->GetOwner()->speed, 0 });*/
23 });
24 exit.Bind([this]() { ani->SetCalled(false);
25
26 //col->OnComponentBeginOverlap.Remove([this](Collider* overlapcomponentself, Collider* othercomponent, Object* otherobject)
27 // {fsm->TransitionState("stand"); });
28 });
29 }
30};
31
32class standstatus :public FSMItems
33{
34public:
35 standstatus(int _status, FSMItems* _parent = nullptr, int _level = 0)
36 :FSMItems(_status, _parent, _level)
37 {
38 enter.Bind(
39 [this]() {
40 if (fsm->GetLastStatus() == std::string("walk"))ani->SetNode("eat"); std::cout << "enter stand status" << std::endl;
41 ani->SetCalled(true);
42 }
43 );
44 act.Bind([this]() {/*if (fsm->GetOwner()->GetWorldPosition().y <= 400) {
45 fsm->TransitionState("idle");
46 }*/});
47 exit.Bind([this]() {
48 /*SpriteRenderer* renderer = fsm->GetOwner()->GetComponentByClass<SpriteRenderer>();
49 renderer->RemoveFilter(1);*/ ani->SetCalled(false); });
50 }
51};
游戏场景中所有碰撞相关事件的处理
分层状态机
物体派生类(精灵类)
void SetNode(std::string name)
设置当前播放的节点.
定义 Animator.cpp:144
void SetCalled(bool called)
设置动画播放器状态 利用当前执行节点计时器来实现控制.
定义 Animator.cpp:183
std::string GetLastStatus()
得到上一次执行的状态名.
定义 FSM.h:436
状态基类.
定义 FSM.h:125
action act
执行事件(每帧执行) 一般用户重写新节点就是添加事件
定义 FSM.h:235
Animator * ani
同物体的动画组件
定义 FSM.h:232
action exit
退出事件 一般用户重写新节点就是添加事件
定义 FSM.h:237
action enter
进入事件 一般用户重写新节点就是添加事件
定义 FSM.h:236
FSM * fsm
绑定的状态机
定义 FSM.h:231
定义 zomblestatus.h:33
standstatus(int _status, FSMItems *_parent=nullptr, int _level=0)
定义 zomblestatus.h:35
定义 zomblestatus.h:8
walkstatus(int _status, FSMItems *_parent=nullptr, int _level=0)
定义 zomblestatus.h:10