mirror of https://github.com/axmolengine/axmol.git
Merge pull request #799 from dumganhar/gles20
issue #1056: Added kazmath license file. Used CCCallFuncN instead of CCCallBlock and updated ActionsTest.
This commit is contained in:
commit
e60dd23825
|
@ -0,0 +1,33 @@
|
|||
Kazmath is a 3D math library aimed at game programming. It is released under the modified BSD license.
|
||||
|
||||
Authors
|
||||
|
||||
Luke Benstead
|
||||
Carsten Haubold
|
||||
|
||||
License
|
||||
|
||||
Copyright (c) 2008, Luke Benstead.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
|
@ -69,10 +69,16 @@ CCLayer* CreateLayer(int nIndex)
|
|||
pLayer = new ActionFollow(); break;
|
||||
case ACTION_TARGETED_LAYER:
|
||||
pLayer = new ActionTargeted(); break;
|
||||
case ACTION_ISSUE1305_LAYER:
|
||||
pLayer = new Issue1305(); break;
|
||||
case ACTION_ISSUE1305_2_LAYER:
|
||||
pLayer = new Issue1305_2(); break;
|
||||
case ACTION_ISSUE1288_LAYER:
|
||||
pLayer = new Issue1288(); break;
|
||||
case ACTION_ISSUE1288_2_LAYER:
|
||||
pLayer = new Issue1288_2(); break;
|
||||
case ACTION_ISSUE1327_LAYER:
|
||||
pLayer = new Issue1327(); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1222,6 +1228,123 @@ std::string ActionTargeted::subtitle()
|
|||
return "Action that runs on another target. Useful for sequences";
|
||||
}
|
||||
|
||||
void Issue1305::onEnter()
|
||||
{
|
||||
ActionsDemo::onEnter();
|
||||
centerSprites(0);
|
||||
|
||||
m_pSpriteTmp = CCSprite::spriteWithFile("Images/grossini.png");
|
||||
/* c++ can't support block, so we use CCCallFuncN instead.
|
||||
[spriteTmp_ runAction:[CCCallBlockN actionWithBlock:^(CCNode* node) {
|
||||
NSLog(@"This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE");
|
||||
}] ];
|
||||
*/
|
||||
|
||||
m_pSpriteTmp->runAction(CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1305::log)));
|
||||
m_pSpriteTmp->retain();
|
||||
|
||||
scheduleOnce(schedule_selector(Issue1305::addSprite), 2);
|
||||
}
|
||||
|
||||
void Issue1305::log(CCNode* pSender)
|
||||
{
|
||||
CCLog("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE");
|
||||
}
|
||||
|
||||
void Issue1305::onExit()
|
||||
{
|
||||
m_pSpriteTmp->release();
|
||||
}
|
||||
|
||||
void Issue1305::addSprite(ccTime dt)
|
||||
{
|
||||
m_pSpriteTmp->setPosition(ccp(250,250));
|
||||
addChild(m_pSpriteTmp);
|
||||
}
|
||||
|
||||
std::string Issue1305::title()
|
||||
{
|
||||
return "Issue 1305";
|
||||
}
|
||||
|
||||
std::string Issue1305::subtitle()
|
||||
{
|
||||
return "In two seconds you should see a message on the console. NOT BEFORE.";
|
||||
}
|
||||
|
||||
void Issue1305_2::onEnter()
|
||||
{
|
||||
ActionsDemo::onEnter();
|
||||
centerSprites(0);
|
||||
|
||||
CCSprite *spr = CCSprite::spriteWithFile("Images/grossini.png");
|
||||
spr->setPosition(ccp(200,200));
|
||||
addChild(spr);
|
||||
|
||||
CCMoveBy* act1 = CCMoveBy::actionWithDuration(2 ,ccp(0, 100));
|
||||
/* c++ can't support block, so we use CCCallFuncN instead.
|
||||
id act2 = [CCCallBlock actionWithBlock:^{
|
||||
NSLog(@"1st block");
|
||||
}];
|
||||
id act3 = [CCMoveBy actionWithDuration:2 position:ccp(0, -100)];
|
||||
id act4 = [CCCallBlock actionWithBlock:^{
|
||||
NSLog(@"2nd block");
|
||||
}];
|
||||
id act5 = [CCMoveBy actionWithDuration:2 position:ccp(100, -100)];
|
||||
id act6 = [CCCallBlock actionWithBlock:^{
|
||||
NSLog(@"3rd block");
|
||||
}];
|
||||
id act7 = [CCMoveBy actionWithDuration:2 position:ccp(-100, 0)];
|
||||
id act8 = [CCCallBlock actionWithBlock:^{
|
||||
NSLog(@"4th block");
|
||||
}];
|
||||
*/
|
||||
|
||||
CCCallFunc* act2 = CCCallFunc::actionWithTarget(this, callfunc_selector(Issue1305_2::log1)) ;
|
||||
CCMoveBy* act3 = CCMoveBy::actionWithDuration(2, ccp(0, -100));
|
||||
CCCallFunc* act4 = CCCallFunc::actionWithTarget(this, callfunc_selector(Issue1305_2::log2)) ;
|
||||
CCMoveBy* act5 = CCMoveBy::actionWithDuration(2, ccp(100, -100));
|
||||
CCCallFunc* act6 = CCCallFunc::actionWithTarget(this, callfunc_selector(Issue1305_2::log3)) ;
|
||||
CCMoveBy* act7 = CCMoveBy::actionWithDuration(2, ccp(-100, 0));
|
||||
CCCallFunc* act8 = CCCallFunc::actionWithTarget(this, callfunc_selector(Issue1305_2::log4)) ;
|
||||
|
||||
CCFiniteTimeAction* actF = CCSequence::actions(act1, act2, act3, act4, act5, act6, act7, act8, NULL);
|
||||
|
||||
// [spr runAction:actF];
|
||||
CCDirector::sharedDirector()->getActionManager()->addAction(actF ,spr, false);
|
||||
|
||||
}
|
||||
|
||||
void Issue1305_2::log1()
|
||||
{
|
||||
CCLog("1st block");
|
||||
}
|
||||
|
||||
void Issue1305_2::log2()
|
||||
{
|
||||
CCLog("2nd block");
|
||||
}
|
||||
|
||||
void Issue1305_2::log3()
|
||||
{
|
||||
CCLog("3rd block");
|
||||
}
|
||||
|
||||
void Issue1305_2::log4()
|
||||
{
|
||||
CCLog("4th block");
|
||||
}
|
||||
|
||||
std::string Issue1305_2::title()
|
||||
{
|
||||
return "Issue 1305 #2";
|
||||
}
|
||||
|
||||
std::string Issue1305_2::subtitle()
|
||||
{
|
||||
return "See console. You should only see one message for each block";
|
||||
}
|
||||
|
||||
void Issue1288::onEnter()
|
||||
{
|
||||
ActionsDemo::onEnter();
|
||||
|
@ -1272,3 +1395,42 @@ std::string Issue1288_2::subtitle()
|
|||
return "Sprite should move 100 pixels, and stay there";
|
||||
}
|
||||
|
||||
|
||||
void Issue1327::onEnter()
|
||||
{
|
||||
ActionsDemo::onEnter();
|
||||
centerSprites(0);
|
||||
|
||||
CCSprite *spr = CCSprite::spriteWithFile("Images/grossini.png");
|
||||
spr->setPosition(ccp(100, 100));
|
||||
addChild(spr);
|
||||
|
||||
CCCallFuncN* act1 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation));
|
||||
CCRotateBy* act2 = CCRotateBy::actionWithDuration(0.25, 45);
|
||||
CCCallFuncN* act3 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation));
|
||||
CCRotateBy* act4 = CCRotateBy::actionWithDuration(0.25, 45);
|
||||
CCCallFuncN* act5 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation));
|
||||
CCRotateBy* act6 = CCRotateBy::actionWithDuration(0.25, 45);
|
||||
CCCallFuncN* act7 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation));
|
||||
CCRotateBy* act8 = CCRotateBy::actionWithDuration(0.25, 45);
|
||||
CCCallFuncN* act9 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation));
|
||||
|
||||
CCFiniteTimeAction* actF = CCSequence::actions(act1, act2, act3, act4, act5, act6, act7, act8, act9, NULL);
|
||||
spr->runAction(actF);
|
||||
}
|
||||
|
||||
std::string Issue1327::title()
|
||||
{
|
||||
return "Issue 1327";
|
||||
}
|
||||
|
||||
std::string Issue1327::subtitle()
|
||||
{
|
||||
return "See console: You should see: 0, 45, 90, 135, 180";
|
||||
}
|
||||
|
||||
void Issue1327::logSprRotation(CCNode* pSender)
|
||||
{
|
||||
CCLog("%f", ((CCSprite*)pSender)->getRotation());
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,11 @@ enum
|
|||
ACTION_ORBIT_LAYER,
|
||||
ACTION_FLLOW_LAYER,
|
||||
ACTION_TARGETED_LAYER,
|
||||
ACTION_ISSUE1305_LAYER,
|
||||
ACTION_ISSUE1305_2_LAYER,
|
||||
ACTION_ISSUE1288_LAYER,
|
||||
ACTION_ISSUE1288_2_LAYER,
|
||||
ACTION_ISSUE1327_LAYER,
|
||||
ACTION_LAYER_COUNT,
|
||||
};
|
||||
|
||||
|
@ -279,6 +282,31 @@ public:
|
|||
virtual std::string subtitle();
|
||||
};
|
||||
|
||||
class Issue1305 : public ActionsDemo
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
void log(CCNode* pSender);
|
||||
void addSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
private:
|
||||
CCSprite* m_pSpriteTmp;
|
||||
};
|
||||
|
||||
class Issue1305_2 : public ActionsDemo
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
void log1();
|
||||
void log2();
|
||||
void log3();
|
||||
void log4();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
};
|
||||
|
||||
class Issue1288 : public ActionsDemo
|
||||
{
|
||||
public:
|
||||
|
@ -295,4 +323,13 @@ public:
|
|||
virtual std::string subtitle();
|
||||
};
|
||||
|
||||
class Issue1327 : public ActionsDemo
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual std::string subtitle();
|
||||
virtual std::string title();
|
||||
void logSprRotation(CCNode* pSender);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue