-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mobcontrol.cpp
47 lines (43 loc) · 1.02 KB
/
Mobcontrol.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "Gamescene.h"
//¶¬
Mobcontrol* Mobcontrol::create(Gamescene* _scene) {
Mobcontrol* ret = new (std::nothrow) Mobcontrol();
if (ret &&ret->init(_scene))
{
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}
//Ź‰Šú‰»
bool Mobcontrol::init(Gamescene* _scene) {
scene = _scene;
mobcreate();
return true;
}
//“G¶¬
void Mobcontrol::mobcreate() {
auto moblist = scene->stagedata->getmoblist();
for (int i = 0; i < moblist.size(); i++) {
static Mob* mob;
switch (moblist.at(i)->mobkind) {
case Mobkind::mob1:
mob = Mob1::create(scene);
break;
case Mobkind::mob2:
mob = Mob2::create(scene);
break;
case Mobkind::mob3:
mob = Mob3::create(scene);
break;
}
static Mapcontrol* map;
map = scene->mapcontrol;
mob->setPosition(map->transblockcentralxy(moblist.at(i)->mobxy.x, moblist.at(i)->mobxy.y));
mob->pbody = PhysicsBody::createCircle(5);
mob->pbody->setRotationEnable(false);
mob->setpbody(Colisionkind::mob, Colisionkind::player);
this->addChild(mob);
}
}