[cpp-tests] 围绕某个精灵(点)作圆周运动
来源:互联网 发布:java 获取绝对路径 编辑:程序博客网 时间:2024/05/21 11:14
cocos2d-x-3.2: cpp-tests
.h:
class SpriteTestDemo : public BaseTest{protected: std::string _title;public: SpriteTestDemo(void); virtual ~SpriteTestDemo(void); void restartCallback(Ref* sender); void nextCallback(Ref* sender); void backCallback(Ref* sender); // overrides virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter() override;};
class SpriteAnchorPoint : public SpriteTestDemo{public: CREATE_FUNC(SpriteAnchorPoint); SpriteAnchorPoint(); virtual std::string title() const override; virtual std::string subtitle() const override;};
cpp实现:
SpriteAnchorPoint::SpriteAnchorPoint(){ auto s = Director::getInstance()->getWinSize(); auto rotate = RotateBy::create(10, 360); auto action = RepeatForever::create(rotate); for(int i=0;i<3;i++) { auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*i, 121*1, 85, 121) ); sprite->setPosition( Vec2( s.width/4*(i+1), s.height/2) ); auto point = Sprite::create("Images/r1.png"); point->setScale( 0.25f ); point->setPosition( sprite->getPosition() ); addChild(point, 10); switch(i) { case 0: sprite->setAnchorPoint( Vec2::ANCHOR_BOTTOM_LEFT );// 左下角 break; case 1: sprite->setAnchorPoint( Vec2::ANCHOR_MIDDLE );// 中心 break; case 2: sprite->setAnchorPoint( Vec2::ANCHOR_TOP_RIGHT );// 右上角 break; } point->setPosition( sprite->getPosition() ); sprite->runAction( action->clone() ); addChild(sprite, i); } }std::string SpriteAnchorPoint::title() const{ return "Testing Sprite";}std::string SpriteAnchorPoint::subtitle() const{ return "anchor point";}
效果图:
0 0
- [cpp-tests] 围绕某个精灵(点)作圆周运动
- UNITY 围绕一个物体做圆周运动
- cocos2dx精灵做正逆时针圆周运动
- (AI-TANK)打击作圆周运动的机器人
- cpp-tests ActionManagerTest
- cpp-tests ActionsEaseTest
- cpp-tests CocosDenshionTest
- cpp-tests ClickAndMoveTest
- cpp-tests ClippingNodeTest--HoleDemo
- cpp-tests FileUtils、FontTest
- cpp-tests IntervalTest(间断)
- cpp-tests Node::Label
- 圆周运动
- cpp-tests Node及NodeTest
- How to Run cpp-tests on win32
- How to run cpp-tests on WIN32
- How to run cpp-tests on Android
- How to run cpp-tests on iOS
- [BZOJ 3043]IncDec Sequence
- 反射机制的一个小实例
- Codility上的练习 (14)
- HDOJ 题目1385 Minimum Transport Cost(最短路,输出路径)
- Zero-Copy&sendfile浅析
- [cpp-tests] 围绕某个精灵(点)作圆周运动
- Int data type
- nginx配置文件分析
- ZOJ(杭电3783)
- Codility上的练习 (15)
- [LeetCode] Spiral Matrix 旋转打印矩阵
- stable_matching算法的java实现.
- 为什么要使用ngnix
- USACO1.1.1 Your Ride Is Here (ride)