-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sheep.cpp
69 lines (59 loc) · 1.33 KB
/
Sheep.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "Sheep.h"
Sheep::Sheep(Scene *ActiveScene, int bitMask)
{
//sheepAni->addSprite("idle","Assets/FireSheep.png");
//sheepAni->addSprite("walk", "Assets /FireSheep.png");
//sheepAni->setAnimation("walk");
AttachedSprite = Sprite::create("Assets/FireSheep.png");
getSprite()->setScale(0.5);
//sheepAni->setAnimationSpeed(.01);
auto size = getSprite()->getContentSize();
getSprite()->setPhysicsBody(PhysicsBody::createBox(size));
getBody()->setTag(5);
getBody()->setName("Sheep");
getBody()->setCollisionBitmask(bitMask);
getBody()->setContactTestBitmask(true);
getBody()->setDynamic(true);
getBody()->setRotationEnable(false);
getBody()->getFirstShape()->setFriction(.25);
ActiveScene->addChild(AttachedSprite);
MaxHP = 200;
HP = 200;
}
Sheep::~Sheep()
{
}
PhysicsBody * Sheep::getBody()
{
return AttachedSprite->getPhysicsBody();
}
Sprite * Sheep::getSprite()
{
return AttachedSprite;
}
void Sheep::setPosition(float x, float y, float z)
{
getSprite()->setPosition3D(Vec3(x, y, 0));
}
Vec2 Sheep::getPosition()
{
return getSprite()->getPosition();
}
SpriteAnimation * Sheep::getSpriteAnimater()
{
return sheepAni;
}
bool Sheep::onDeath()
{
if (sheep1 == true)
{
setHP(200);
setPosition(400, 350, 0);
sheep1 = false;
}
else if (sheep1 == false && sheep2 == true)
{
sheep2 = false;
}
else return false;
}