Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don't Merge] FadeIn is crashed on windows. #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions Cocos2DX_3.x/Demos/Classes/AppDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ bool AppDelegate::applicationDidFinishLaunching() {
FileUtils::getInstance()->addSearchPath("res");

// create a scene. it's an autorelease object
//auto scene = HelloDragonBones::createScene();
auto scene = HelloDragonBones::createScene();
//auto scene = PerformanceTest::createScene();
//auto scene = AnimationBaseTest::createScene();
//auto scene = KnightGame::createScene();
auto scene = CoreElementGame::createScene();
//auto scene = CoreElementGame::createScene();

// run
director->runWithScene(scene);
Expand Down
49 changes: 38 additions & 11 deletions Cocos2DX_3.x/Demos/Classes/HelloDragonBones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,30 @@ bool HelloDragonBones::init()
_armatureDisplay = nullptr;

// Load DragonBones Data.
_dragonBonesData = _factory.loadDragonBonesData("DragonBoy/DragonBoy.json");
_factory.loadTextureAtlasData("DragonBoy/DragonBoy_texture_1.json");
_dragonBonesData = _factory.loadDragonBonesData("FadeInCrash/16_ske.json");
_factory.loadTextureAtlasData("FadeInCrash/16_tex.json");

if (_dragonBonesData)
{
_changeArmature();
_changeAnimation();

const auto listener = cocos2d::EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(HelloDragonBones::_touchBeganHandler, this);
listener->onTouchEnded = CC_CALLBACK_2(HelloDragonBones::_touchEndedHandler, this);
listener->onTouchMoved = CC_CALLBACK_2(HelloDragonBones::_touchMovedHandler, this);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
_armatureDisplay = _factory.buildArmatureDisplay("armatureName");
_armature = _armatureDisplay->getArmature();

const auto center = cocos2d::Director::getInstance()->getVisibleSize();
_armatureDisplay->setPosition(center.width * 0.5f, center.height * 0.5f);
_armatureDisplay->setScale(_armatureScale);
this->addChild(_armatureDisplay);

_armature->getAnimation().fadeIn("Z公主-定帧", 0, 1, 0, "gongzhu", dragonBones::AnimationFadeOutMode::SameGroup);
_armature->getAnimation().fadeIn("Z男孩-定帧", 0, 1, 0, "nanhai", dragonBones::AnimationFadeOutMode::SameGroup);
_armatureDisplay->addEvent(dragonBones::EventObject::COMPLETE, std::bind(&HelloDragonBones::_frameEventHandler, this, std::placeholders::_1));
// _changeArmature();
// _changeAnimation();

// const auto listener = cocos2d::EventListenerTouchOneByOne::create();
// listener->onTouchBegan = CC_CALLBACK_2(HelloDragonBones::_touchBeganHandler, this);
// listener->onTouchEnded = CC_CALLBACK_2(HelloDragonBones::_touchEndedHandler, this);
// listener->onTouchMoved = CC_CALLBACK_2(HelloDragonBones::_touchMovedHandler, this);
// this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
}
else
{
Expand All @@ -56,6 +67,22 @@ bool HelloDragonBones::init()
return true;
}

void HelloDragonBones::_frameEventHandler(dragonBones::EventObject* event)
{
auto eventType = event->type;
auto animName = event->animationState->getName();

if (strcmp(eventType.c_str(), dragonBones::EventObject::COMPLETE) == 0) {

if (strcmp("Z公主-定帧", animName.c_str()) == 0) {
_armature->getAnimation().fadeIn("动画-公主-定帧", 0, 1, 0, "gongzhu", dragonBones::AnimationFadeOutMode::SameGroup);
} else if (strcmp("Z男孩-定帧", animName.c_str()) == 0) {

_armature->getAnimation().fadeIn("动画-男孩-定帧", 0, 1, 0, "nanhai", dragonBones::AnimationFadeOutMode::SameGroup);
}
}
}

void HelloDragonBones::_changeArmature()
{
const auto& armatureNames = _dragonBonesData->getArmatureNames();
Expand Down Expand Up @@ -162,4 +189,4 @@ void HelloDragonBones::_touchMovedHandler(const cocos2d::Touch* touch, cocos2d::
_isMoved = true;
_armatureScale = std::max((touch->getLocation().y - _startPoint.y) / 200.f + _prevArmatureScale, 0.1f);
_armatureDisplay->setScale(_armatureScale);
}
}
1 change: 1 addition & 0 deletions Cocos2DX_3.x/Demos/Classes/HelloDragonBones.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class HelloDragonBones : public cocos2d::LayerColor
dragonBones::CCArmatureDisplay* _armatureDisplay;
dragonBones::CCFactory _factory;

void _frameEventHandler(dragonBones::EventObject* event);
void _changeArmature();
void _changeAnimation();

Expand Down
1 change: 1 addition & 0 deletions Cocos2DX_3.x/Demos/Resources/res/FadeInCrash/16_ske.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cocos2DX_3.x/Demos/Resources/res/FadeInCrash/16_tex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"SubTexture":[{"width":960,"y":543,"height":540,"name":"图1","x":1},{"width":101,"y":1288,"height":116,"name":"喵头","x":426},{"width":40,"y":1444,"height":37,"name":"猫手","x":277},{"width":57,"y":1516,"height":42,"name":"猫身体","x":207},{"width":21,"y":1483,"height":10,"name":"猫手-藏起来","x":147},{"width":960,"y":1,"height":540,"name":"墙壁","x":1},{"width":117,"y":1085,"height":173,"name":"男孩","x":614},{"width":41,"y":1557,"height":83,"name":"男孩手2","x":1},{"width":68,"y":1552,"height":63,"name":"男孩手1","x":72},{"width":58,"y":1516,"height":83,"name":"男孩领子","x":147},{"width":180,"y":1272,"height":200,"name":"男孩头","x":1},{"width":37,"y":1497,"height":12,"name":"男孩(睁眼)","x":277},{"width":34,"y":1474,"height":7,"name":"男孩(闭眼)","x":147},{"width":103,"y":1260,"height":155,"name":"公主头","x":614},{"width":38,"y":1483,"height":12,"name":"公主(睁眼)","x":277},{"width":73,"y":1474,"height":76,"name":"公主手2","x":72},{"width":181,"y":1085,"height":201,"name":"公主","x":431},{"width":69,"y":1474,"height":81,"name":"公主手1","x":1},{"width":92,"y":1444,"height":70,"name":"国王手2","x":183},{"width":89,"y":1272,"height":168,"name":"国王手1","x":335},{"width":96,"y":1085,"height":180,"name":"国王","x":733},{"width":150,"y":1272,"height":170,"name":"国王头","x":183},{"width":81,"y":1442,"height":142,"name":"叠层-男孩","x":335},{"width":81,"y":1288,"height":142,"name":"叠层-国王","x":529},{"width":81,"y":1406,"height":142,"name":"叠层-公主","x":426},{"frameX":-65,"frameHeight":337,"y":1085,"frameY":-71,"frameWidth":337,"width":213,"height":185,"name":"心","x":1},{"frameX":-65,"frameHeight":337,"y":1085,"frameY":-71,"frameWidth":337,"width":213,"height":185,"name":"心1","x":216},{"width":37,"y":1511,"height":9,"name":"公主(闭眼)","x":277}],"name":"故事飞船06期部分-17(起始帧调整)","imagePath":"16_tex.png"}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.