标签:
首先,需要学会创建精灵:
1 auto mySprite = Sprite::create("mysprite.png"); 2 auto mySprite = Sprite::create("mysprite.png",Rect(0,0,200,200));
然后改变他们的属性(七个基本属性):
1 mySprite->setAnchorPoint(0.5, 0.5);// 所有精灵默认锚点 2 mySprite->setAnchorPoint(0, 0); // 左下角 3 mySprite->setAnchorPoint(0, 1); // 左上角 4 mySprite->setAnchorPoint(1, 0); // 右下角 5 mySprite->setAnchorPoint(1, 1); // 右上角
// 让精灵到坐标(100,200) mySprite->setPosition(Vec2(100, 200));
顺时针为+,逆时针为-
1 mySprite->setRotation(20.0f); // 顺时针旋转20度 2 mySprite->setRotation(-20.0f);// 逆时针旋转20度 3 mySprite->setRotation(60.0f); // 顺时针旋转60度 4 mySprite->setRotation(-60.0f);// 逆时针旋转60度
1 mySprite->setScale(2.0); //比例增大两倍 2 mySprite->setScaleX(2.0);//X 轴增大两倍 3 mySprite->setScaleY(2.0);//Y 轴增大两倍
1 //X轴倾斜20度 2 mySprite->setSkewX(20.0f); 3 //Y轴倾斜20度 4 mySprite->setSkewY(20.0f);
1 //设置颜色要通过Color3B对象 2 mySprite->setColor(Color3B(255, 255, 255)); 3 //也能用通过Color3B对象的默认颜色来设置 4 mySprite->setColor(Color3B::White);
//通过特定的值来改变精灵的透明度。取值范围为(2~255),默认值为255(不透明) mySprite->serOpacity(30);
参考资料:http://cn.cocos2d-x.org/tutorial/show?id=1989
标签:
原文地址:http://www.cnblogs.com/cocoslhr/p/4658736.html