cocos study notes-Sprite

cocos study notes-Sprite

Reference: [jellythink](“http://www.jellythink.com/archives/742“)

1.Sprite class

Sprite is a 2D picture object,which can be defined by using a picture or part of picture.A Sprite can move, rotate, play action and so on. It consist of Texture,Frame,Animation.

important:

We usually use Texture2D to load the picture, then use it to produce SpriteFrame.After that , we add SpriteFrame to the Animation to produce action data.Finally, Animation produces Animate.Then Sprite puts it into action.

2.Sprite

API:

//create an empty sprite and then use `setTexture` to set the texture
static Sprite* create();
//create a sprite with an image
static Sprite* create(const std::string& filename);
//create a sprite with a Texture2D object
static Sprite* createWithTexture(Texture2D* texture);
//create a sprite by using spriteframe
static Sprite* createWithSpriteFrame(SpriteFrame *spriteFrame);
/*create a sprite by using a spriteframe,inside the programe, IDE will get `SpriteFrame` from `SpriteFrameCache` according to `SpriteFrameName` parameter */
static Sprite* createWithSpriteFrameName(const std::string& spriteFrameName)

3.SpriteBatchNode

If we need to render many sprites,we can use SpriteBatchNode to render them in one time to save spending,like this:

auto batchNode = SpriteBatchNode::create("CloseNormal.png", 1000);
batchNode->setPosition(Point::ZERO);
this->addChild(batchNode);
for (int i = 0;i < 1000;i++)
{
    int x = rand() % 960;
    int y = rand() % 640;
    auto testIcon = Sprite::createWithTexture(batchNode->getTexture());
    testIcon->setPosition(ccp(x, y));
    batchNode->addChild(testIcon);
}
cocos-to-playable-ad是一种将Cocos Creator游戏引擎中开发的游戏转化为可玩广告的解决方案。在移动广告行业中,可玩广告已经成为吸引用户和提高点击率的一种重要方式。通过将游戏转化为可玩广告,广告主可以更好地展示他们的产品和服务,并吸引更多的用户进行真实游戏体验。 cocos-to-playable-ad解决方案提供了一个简便而高效的工具,使开发者能够将他们在Cocos Creator中开发的游戏快速转化为可玩广告。开发者只需将游戏项目导入到该工具中,选择相应的广告平台和相关设置,即可生成对应的可玩广告。 通过cocos-to-playable-ad,开发者能够自定义广告的展示内容和交互方式,使广告更具吸引力和互动性。该解决方案还支持多种广告平台,如Google AdMob、Facebook Audience Network等,使开发者能够轻松地将可玩广告投放到不同的渠道中。 从广告主的角度来看,cocos-to-playable-ad使他们能够用更直观的方式展示他们的产品和服务。用户可以亲身体验游戏的玩法和特色功能,从而更好地了解广告主的产品,并在游戏体验中与广告互动。这种形式的广告更容易吸引用户的注意力,提高点击率和转化率。 总之,cocos-to-playable-ad提供了一种方便、快捷的方式,将Cocos Creator游戏转化为可玩广告。它为开发者和广告主提供了一个更具吸引力和互动性的广告形式,帮助他们更好地展示产品和服务,并吸引更多的用户。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值