节点对象自身锚点改变对运动方法不影响。运动方法To依靠原点坐标,By依靠节点对象中心。
参考博文
ps: 最下面的黑边是游戏窗口(pc)左下角边,那(0,0) (0,200)错了,origin在外面.画图工具太拉了,不想改了。
auto origin = Director::getInstance()->getVisibleOrigin();
auto s5 = Sprite::create("5.png");
s5->setPosition(origin + (s5->getContentSize() / 2.0f));
auto s5_contentSize = s5->getContentSize();
auto action_1 = MoveTo::create(1.0, Vec2(100,100));
auto action_2 = MoveBy::create(1.0, Vec2(-(100 - origin.x - (s5_contentSize.width / 2.0f)), 100 - origin.y - (s5_contentSize.height / 2.0f)));
auto delay = DelayTime::create(0.5f);
s5->runAction(Sequence::create(delay, action_1, delay->clone(), action_2, nullptr));
this->addChild(s5);
思考:
m*,为啥origin默认在屏幕之外?!坐标系原点应该可以改到屏幕左下角吧?
扩展
cocos2d-x坐标系详解
|