Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Classes/AppDelegate.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "AppDelegate.h"
#include "Scenes/WelcomeScene.h"
#include "Scenes/ExampleGameScene.h"
#include "Scenes/OnlineGameScene.h"
#include "Scenes/SocketServerScene.h"
#include "Scenes/InputNameScene.h"

// #define USE_AUDIO_ENGINE 1
// #define USE_SIMPLE_AUDIO_ENGINE 1
Expand Down Expand Up @@ -96,7 +99,9 @@ bool AppDelegate::applicationDidFinishLaunching() {

// create a scene. it's an autorelease object
auto scene = WelcomeScene::createScene();

//auto scene = SocketServerScene::createScene();
//auto scene = ExampleGameScene::createScene();

// run
director->runWithScene(scene);

Expand Down
92 changes: 91 additions & 1 deletion Classes/Players/Charactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,98 @@ Charactor::Charactor(string _name) {
hitEffectBegin = 53;
hitEffectEnd = 60;//��������Ч
}
else {
else if (name == "Goku") {
idleNum = 4;
runNum = 6;
meleeAttack1Num = 4;
meleeAttack2Num = 9;
meleeAttack3Num = 15;
rangedAttackNum = 6;
jumpNum = 7;
hitNum = 2;
deadNum = 5;
winNum = 8;
hittedAwayNum = 7; //todo
dashNum = 2;
defendNum = 1;
chargeNum = 4;
ultimateNum = 10;

ultimateBallNum = 4;
ultimateBallBegin = 11;
ultimateBallEnd = 14;//����
chargeEffectNum = 11;
chargeEffectBegin = 0;
chargeEffectEnd = 10;//����
rangedBallNumber = 30;//Զ�̹���
explosionNum = 17;
explosionBegin = 31;
explosionEnd = 47;//��ը
hitEffectNum = 8;
hitEffectBegin = 53;
hitEffectEnd = 60;//��������Ч
}
else if (name == "Frieza") {
idleNum = 3;
runNum = 8;
meleeAttack1Num = 4;
meleeAttack2Num = 7;
meleeAttack3Num = 11;
rangedAttackNum = 6;
jumpNum = 7;
hitNum = 2;
deadNum = 4;
winNum = 5;
hittedAwayNum = 7;
dashNum = 2;
defendNum = 1;
chargeNum = 4;
ultimateNum = 5;

ultimateBallNum = 4;
ultimateBallBegin = 11;
ultimateBallEnd = 14;//����
chargeEffectNum = 11;
chargeEffectBegin = 0;
chargeEffectEnd = 10;//����
rangedBallNumber = 30;//Զ�̹���
explosionNum = 17;
explosionBegin = 31;
explosionEnd = 47;//��ը
hitEffectNum = 8;
hitEffectBegin = 53;
hitEffectEnd = 60;//��������Ч
}
else if (name == "Vegeta") {
idleNum = 4;
runNum = 6;
meleeAttack1Num = 5;
meleeAttack2Num = 12;
meleeAttack3Num = 17;
rangedAttackNum = 5;
jumpNum = 7;
hitNum = 2;
deadNum = 5;
winNum = 6;
hittedAwayNum = 2; //
dashNum = 4; //
defendNum = 1;
chargeNum = 4;
ultimateNum = 7;

ultimateBallNum = 4;
ultimateBallBegin = 11;
ultimateBallEnd = 14;//����
chargeEffectNum = 11;
chargeEffectBegin = 0;
chargeEffectEnd = 10;//����
rangedBallNumber = 30;//Զ�̹���
explosionNum = 17;
explosionBegin = 31;
explosionEnd = 47;//��ը
hitEffectNum = 8;
hitEffectBegin = 53;
hitEffectEnd = 60;//��������Ч
}

rangedBallStr = name + "_boom_" + std::to_string(rangedBallNumber) + ".png";
Expand Down
1 change: 1 addition & 0 deletions Classes/Players/Charactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Charactor
char* getBoomStr1() { return (char*)boomStr1.data(); }
char* getBoomStr2() { return (char*)boomStr2.data(); }
char* getRangedBallStr() { return (char*)rangedBallStr.data(); }
string getName() { return name; }

int getIdleNum() { return idleNum; }
int getRunNum() { return runNum; }
Expand Down
50 changes: 42 additions & 8 deletions Classes/Players/PlayerSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ void PlayerSprite::initSprite(std::string name, Sprite* player)
damage = EXAMPLE_PLAYER_DAMAGE;
speed = EXAMPLE_PLAYER_SPEED;
height = EXAMPLE_PLAYER_HEIGHT;
try {
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(name + ".plist");
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(name + "_boom.plist");
}
catch (exception err) {
log("error %s.plist", name.c_str());
log("error %s_boom.plist", name.c_str());
}
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(name + ".plist");
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(name + "_boom.plist");
charactor = new Charactor(name);
Expand Down Expand Up @@ -207,6 +215,7 @@ void PlayerSprite::moveLeft()
if (isRun) {
return;
}
isMove = true;
auto animation = Animation::createWithSpriteFrames(runVector, 0.09f);
auto animate = Animate::create(animation);
auto MoveAnimate = RepeatForever::create(animate);
Expand All @@ -229,6 +238,7 @@ void PlayerSprite::moveRight()
if (isRun) {
return;
}
isMove = true;
auto animation = Animation::createWithSpriteFrames(runVector, 0.09f);
auto animate = Animate::create(animation);
auto MoveAnimate = RepeatForever::create(animate);
Expand Down Expand Up @@ -381,12 +391,18 @@ void PlayerSprite::hit()
if (isRun) {
return;
}
if (hittedCount < 3) {
if (hp >= 5) {
hp -= 5;
if (abs(getPositionX()) < 30.0 || abs(getPositionX() - 1022.0) < 30.0 || hittedCount < 3) {
hittedCount %= 3;
if (isDefend) {
isDefend = false;
}
else {
hp = 0;
if (hp >= 5) {
hp -= 5;
}
else {
hp = 0;
}
}
auto begin = CallFuncN::create([&](Ref* sender) {
isHitted = true;
Expand Down Expand Up @@ -415,6 +431,9 @@ void PlayerSprite::dead()
{
stopAllActions();
isDead = true;
if (charactor->getName() == "Vegeta") {
setPosition(getPosition() - Vec2(0, 30));
}
auto animation = Animation::createWithSpriteFrames(deadVector, 0.25f);
auto animate = Animate::create(animation);
animate->setOriginalTarget(false);
Expand All @@ -431,13 +450,22 @@ void PlayerSprite::hitByUltimate()
else {
hp = 0;
}
stopAllActions();
isDefend = false;
auto begin = CallFuncN::create([&](Ref* sender) {
ishitByUltimate = true;
});

auto animation = Animation::createWithSpriteFrames(deadVector, 0.25f);
auto animate = Animate::create(animation);
auto end = CallFuncN::create([&](Ref* sender) {;
idle();
idle();
ishitByUltimate = false;
});
auto seq = Sequence::create(animate, DelayTime::create(0.2f), end, NULL);

/* seq �������൱�� animate �����ӳ� 2f ִ�� end ���� */
auto seq = Sequence::create(begin, animate, DelayTime::create(0.2f), end, NULL);
stopAllActions();
stopActionByTag(3);
runAction(seq);
}

Expand All @@ -447,6 +475,7 @@ void PlayerSprite::dashLeft(Vec2 oppoentPosition)
if (isRun) {
return;
}
isMove = true;
setFlippedX(false);
physicPlayer->getPhysicsBody()->setVelocity(Vec2(-800,0));
auto animation = Animation::createWithSpriteFrames(dashVector, 0.09f, 0);
Expand All @@ -462,6 +491,7 @@ void PlayerSprite::dashRight(Vec2 oppoentPosition)
if (isRun) {
return;
}
isMove = true;
setFlippedX(true);
physicPlayer->getPhysicsBody()->setVelocity(Vec2(800, 0));
auto animation = Animation::createWithSpriteFrames(dashVector, 0.09f, 0);
Expand All @@ -474,6 +504,9 @@ void PlayerSprite::dashRight(Vec2 oppoentPosition)
void PlayerSprite::win() {
stopAllActions();
isWin = true;
if (charactor->getName() == "Goku") {
setPosition(getPosition() + Vec2(0, 70));
}
auto animation = Animation::createWithSpriteFrames(winVector, 0.25f);
auto animate = Animate::create(animation);
animate->setOriginalTarget(false);
Expand Down Expand Up @@ -543,6 +576,7 @@ void PlayerSprite::defend() {
if (isRun) {
return;
}
isDefend = true;
auto animation = Animation::createWithSpriteFrames(defendVector, 0.09f);
auto animate = Animate::create(animation);
auto act = RepeatForever::create(animate);
Expand All @@ -553,7 +587,7 @@ void PlayerSprite::defend() {

/* ���� */
void PlayerSprite::charge() {
if (isRun) {
if (getActionByTag(0) == NULL) {
return;
}
auto end = CallFuncN::create([&](Ref* sender) {
Expand Down
3 changes: 3 additions & 0 deletions Classes/Players/PlayerSprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ class PlayerSprite : public Sprite

#pragma region �����жϵ�ǰ��ɫ��״̬

bool ishitByUltimate = false;
bool isRun = false;
bool stopJump = true, stopMeleeAttack = true, stopRangedAttack = true;
bool isHitted = false, isHitting = false, isUltimate = false;
bool isDead = false, isWin = false;
bool isMove = false;
bool isDefend = false;
int hittedCount = 0;
/*���������жϱ���*/
bool isDouble = false;
Expand Down
Loading