Small fix in ArmatureScene.cpp/.h

This commit is contained in:
James Chen 2014-01-07 20:54:34 +08:00
parent c7639319ee
commit 7a52d2aad7
2 changed files with 9 additions and 8 deletions

View File

@ -1023,7 +1023,7 @@ void TestColliderDetector::update(float delta)
// This code is just telling how to get the vertex. // This code is just telling how to get the vertex.
// For a more accurate collider detection, you need to implemente yourself. // For a more accurate collider detection, you need to implemente yourself.
const Map<std::string, Bone*>& map = armature2->getBoneDic(); const Map<std::string, Bone*>& map = armature2->getBoneDic();
for(auto element : map) for(const auto& element : map)
{ {
Bone *bone = element.second; Bone *bone = element.second;
ColliderDetector *detector = bone->getColliderDetector(); ColliderDetector *detector = bone->getColliderDetector();
@ -1033,12 +1033,12 @@ void TestColliderDetector::update(float delta)
const cocos2d::Vector<ColliderBody*>& bodyList = detector->getColliderBodyList(); const cocos2d::Vector<ColliderBody*>& bodyList = detector->getColliderBodyList();
for (auto object : bodyList) for (const auto& object : bodyList)
{ {
ColliderBody *body = static_cast<ColliderBody*>(object); ColliderBody *body = static_cast<ColliderBody*>(object);
const std::vector<Point> &vertexList = body->getCalculatedVertexList(); const std::vector<Point> &vertexList = body->getCalculatedVertexList();
float minx, miny, maxx, maxy = 0; float minx = 0, miny = 0, maxx = 0, maxy = 0;
int length = vertexList.size(); int length = vertexList.size();
for (int i = 0; i<length; i++) for (int i = 0; i<length; i++)
{ {
@ -1264,7 +1264,7 @@ void TestArmatureNesting2::onEnter()
touchedMenu = false; touchedMenu = false;
LabelTTF* label = CCLabelTTF::create("Change Mount", "Arial", 20); LabelTTF* label = CCLabelTTF::create("Change Mount", "Arial", 20);
MenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, CC_CALLBACK_1(TestArmatureNesting2::ChangeMountCallback, this)); MenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, CC_CALLBACK_1(TestArmatureNesting2::changeMountCallback, this));
Menu* pMenu =Menu::create(pMenuItem, nullptr); Menu* pMenu =Menu::create(pMenuItem, nullptr);
@ -1321,7 +1321,7 @@ void TestArmatureNesting2::onTouchesEnded(const std::vector<Touch*>& touches, Ev
armature->runAction(Sequence::create(move, nullptr)); armature->runAction(Sequence::create(move, nullptr));
} }
void TestArmatureNesting2::ChangeMountCallback(Object* pSender) void TestArmatureNesting2::changeMountCallback(Object* pSender)
{ {
hero->stopAllActions(); hero->stopAllActions();

View File

@ -336,15 +336,16 @@ public:
class TestArmatureNesting2 : public ArmatureTestLayer class TestArmatureNesting2 : public ArmatureTestLayer
{ {
public: public:
virtual void onEnter(); virtual void onEnter() override;
virtual void onExit(); virtual void onExit() override;
virtual std::string title() const override; virtual std::string title() const override;
virtual std::string subtitle() const override; virtual std::string subtitle() const override;
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event); void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
virtual void ChangeMountCallback(Object* pSender); void changeMountCallback(Object* pSender);
virtual cocostudio::Armature *createMount(const char *name, Point position); virtual cocostudio::Armature *createMount(const char *name, Point position);
private:
Hero *hero; Hero *hero;
cocostudio::Armature *horse; cocostudio::Armature *horse;