Sprite是cocos2d-x引擎中最常用的节点称为精灵
可以把精灵看作cocos2d-x中的舞者具有各种动作和表演能力
// 显示原点坐标, 一般为(0,0)
Vec2 orign = Director::getInstance()->getVisibleOrigin();
// 得到显示的大小
auto position = Director::getInstance()->getVisibleSize();
// 设置创建多边形精灵, 性能更好
auto pinfo = AutoPolygon::generatePolygon("Blover_head.png");
// 创建精灵
auto temppng = Sprite::create(pinfo);
// 设置坐标
temppng->setPosition(Vec2(position.width / 2 + orign.x, position.height / 2 + orign.y));
// 设置锚点
temppng->setAnchorPoint(Vec2(0.5f, 0.5f));
// 旋转
temppng->setRotation(20.0f);
// 缩放
temppng->setScale(2.0);
// 倾斜
temppng->setSkewX(10.0f);
// 设置颜色
temppng->setColor(Color3B::RED);
// 设置透明度 0 - 255// 255 是完全不透明
temppng->setOpacity(230);
// 添加到场景
this->addChild(temppng);
// Action动作
// 移动, 用时两秒, X坐标加50
auto moveBy = MoveBy::create(2, Vec2(50, 3));
// 精灵执行action
temppng->runAction(moveBy);
// 旋转
auto retateto = RotateTo::create(2, 90);
temppng->runAction(retateto);
// 色彩混合, 2秒之内颜色变为
auto tinto = TintTo::create(2.0f, 120.0f, 232.0f, 254.0f);
temppng->runAction(tinto);