cocos2d3.0 Scale9Sprite
使用Scale9Sprite须要引入以下的头文件
#include "extensions/cocos-ext.h" USING_NS_CC;
USING_NS_CC_EXT;
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
} Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); float x = visibleSize.width / 2;
float y = visibleSize.height / 2; auto batchNode = SpriteBatchNode::create("blocks9.png"); auto blocks = Scale9Sprite::create();
log("------created"); blocks->updateWithBatchNode(batchNode, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); blocks->setPosition(Point(x, y)); this->addChild(blocks);
return true;
}
效果:
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
} Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("blocks9ss.plist");
float x = visibleSize.width / 2;
float y = visibleSize.height / 2; auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); blocks->setPosition(Point(x, y)); this->addChild(blocks); return true;
}
效果:
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
} Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("blocks9ss.plist");
float x = visibleSize.width / 2;
float y = visibleSize.height / 2; auto batchNode_scaled = SpriteBatchNode::create("blocks9.png"); auto block_scaled = Scale9Sprite::create(); block_scaled->updateWithBatchNode(batchNode_scaled, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); block_scaled->setPosition(Point(x, y)); block_scaled->setContentSize(Size(96 * 4, 96 * 2)); this->addChild(block_scaled); return true;
}
效果:
auto block_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9.png");
block_scaled->setPosition(Point(x, y));
block_scaled->setContentSize(Size(96 * 4, 96 * 2));
this->addChild(block_scaled);
效果:
auto block_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9r.png");
block_scaled->setPosition(Point(x, y));
block_scaled->setContentSize(Size(96 * 4, 96 * 2));
this->addChild(block_scaled);
效果:
S9FrameNameSpriteSheetInsets
auto batchNode_scaled_with_insets = SpriteBatchNode::create("blocks9.png");
auto blocks_scaled_with_insets = Scale9Sprite::create();
blocks_scaled_with_insets->updateWithBatchNode(batchNode_scaled_with_insets, Rect(0, 0, 96, 96), false, Rect(32, 32, 32, 32));
blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5));
blocks_scaled_with_insets->setPosition(Point(x, y));
this->addChild(blocks_scaled_with_insets);
S9FrameNameSpriteSheetInsetsScaled
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("blocks9ss.plist");
float x = visibleSize.width / 2;
float y = visibleSize.height / 2; auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png",Rect(32, 32, 32, 32)); blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); blocks_scaled_with_insets->setPosition(Point(x, y)); this->addChild(blocks_scaled_with_insets);
S9_TexturePacker
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("ui.plist");
float x = visibleSize.width / 4;
float y = visibleSize.height / 2; auto s = Scale9Sprite::createWithSpriteFrameName("button_normal.png"); s->setPosition(Point(x, y));
log("... setPosition"); s->setContentSize(Size(14 * 16, 10 * 16));
log("... setContentSize"); this->addChild(s); auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("button_actived.png"); x = visibleSize.width * 3/4;
blocks_scaled_with_insets->setContentSize(Size(14 * 16, 10 * 16)); blocks_scaled_with_insets->setPosition(Point(x , y)); this->addChild(blocks_scaled_with_insets);
Scale9FrameNameSpriteSheetRotatedSetCapInsetLater
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("blocks9ss.plist");
float x = visibleSize.width / 2;
float y = visibleSize.height / 2; auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png");
blocks_scaled_with_insets->setInsetLeft(32);
blocks_scaled_with_insets->setInsetRight(32);
blocks_scaled_with_insets->setPreferredSize(Size(32 * 5.5f, 32 * 4)); blocks_scaled_with_insets->setPosition(Point(x , y)); this->addChild(blocks_scaled_with_insets);
S9CascadeOpacityAndColor
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("blocks9ss.plist");
float x = visibleSize.width / 2;
float y = visibleSize.height / 2; auto rgba = Layer::create();
rgba->setCascadeColorEnabled(true);
rgba->setCascadeOpacityEnabled(true);
this->addChild(rgba); auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); blocks_scaled_with_insets->setPosition(Point(x , y)); rgba->addChild(blocks_scaled_with_insets); auto actions = Sequence::create(FadeIn::create(1),TintTo::create(1, 0, 255, 0),TintTo::create(1, 255, 255, 255),FadeOut::create(1), NULL);
auto repeat = RepeatForever::create(actions); rgba->runAction(repeat);
cocos2d3.0 Scale9Sprite的更多相关文章
- cocos2d3.0跑酷代码讲解和源码
最近在网上看到一个跑酷代码的例子,写的很不错,连接如下 http://www.waitingfy.com/archives/783 现在我把他精简了一下,去除了一些比较简单的特效,着重保留了主角的跳跃 ...
- Cocos2d3.0 制作PList文件
auto root = Dictionary::create(); auto string = String::create("string element value"); ro ...
- cocos2d-3.0 Helloworld::onTouchMoved的处理机制的推測
bool sign2 = true; bool sign2 = true; void GameLayer::onTouchMoved(Touch *touch, Event *unused){ if( ...
- [原创]cocos2dx加载网络图片&异步加载图片
[动机] 之前看到一款卡牌游戏,当你要看全屏高清卡牌的时候,游戏会单独从网络上下载,本地只存了非高清的,这样可以省点包大小,所以我萌生了实现一个读取网络图片的类. [联想] 之前浏览网页的时候经常看到 ...
- 使用cocostudio 需要在Android.mk文件的配置
直接贴上Android.mk文件吧. 对了,是cocos2d3.0的,不知道2.x是否一样. LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LO ...
- Cocos2d-x移植安卓的笔记
一.下载所需软件 Java SDK http://www.oracle.com/technetwork/java/javase/downloads/index.html Windows x64 ...
- ZAM 3D 制作简单的3D字幕 流程(二)
原地址:http://www.cnblogs.com/yk250/p/5663907.html 文中表述仅为本人理解,若有偏差和错误请指正! 接着 ZAM 3D 制作简单的3D字幕 流程(一) .本篇 ...
- ZAM 3D 制作3D动画字幕 用于Xaml导出
原地址-> http://www.cnblogs.com/yk250/p/5662788.html 介绍:对经常使用Blend做动画的人来说,ZAM 3D 也很好上手,专业制作3D素材的XAML ...
- 微信小程序省市区选择器对接数据库
前言,小程序本身是带有地区选着器的(网站:https://mp.weixin.qq.com/debug/wxadoc/dev/component/picker.html),由于自己开发的程序的数据是很 ...
随机推荐
- PostGreSQL数据库安装配置说明
windows 10 x64 pro 1703安装postgresql-9.6.3-2-windows-x64.exe数据库,步骤如下: 第一:下载数据库安装程序,下载地址为:https://www. ...
- Fiddler Web Session 列表(1)
Web Session 列表 位置: Web Session 列表 位于Fiddler界面的左侧 ,是Fiddler所抓取到的所有Session会话的列表集合. Web Session 列表 栏名词解 ...
- Netty性能调优
1. 减少内存allocation和deallocation.通过静态实例和内存缓存,减少IO的次数. 2. 使用gather write和scatter read 3. 使用jDK7,因为他的byt ...
- java EE : http 协议之请求报文、响应报文
1 HTTP协议特点 1)客户端->服务端(请求request)有三部份 a)请求行 b)请求头 c)请求的内容,如果没有,就是空白字符 2)服务端->客户端(响应response)有三部 ...
- 【LOJ】#2544. 「JXOI2018」游戏
题解 九条可怜还有那么善良的一面??? 显然有些数在这个区间里没有数是它的约数,它们其中的最后一个取的一定就是\(t(p)\)的值 这样我们只需要枚举\(t(p)\)的值,这个值就是"没有任 ...
- 记一次ceph集群的严重故障
问题:集群状态,坏了一个盘,pg状态好像有点问题[root@ceph-1 ~]# ceph -s cluster 72f44b06-b8d3-44cc-bb8b-2048f5b4acfe ...
- php将长字符串拆分为指定最大宽度的字符串数组
/** * 将字符串拆分为指定最大宽度的字符串数组.单字节字符宽度为1,多字节字符通常宽度为2 * @param string $msg 要拆分的字符串 * @param int $width 结果数 ...
- ref:spring-data-XMLBean XXE复现分析
ref:https://blog.spoock.com/2018/05/16/cve-2018-1259/ 漏洞信息 看pivotal发布的漏洞信息如下 通过发布的漏洞信息可以知道,漏洞组件是在XML ...
- Linux下安装scapy-python3
安装scapy # pip3 install scapy-python3 # yum install libffi-devel # pip3 install cryptography 新建scapy软 ...
- HashMap实现原理及常见问题
1.简介 HashMap是基于哈希表的Map接口的实现,用来存放键值对(Entry<Key,Value>),并提供可选的映射操作.使用put(Key,Value)存储对象到HashMap中 ...