SpriteBuilder中的CCSprite9Slice是个什么鬼?
2015-09-28 16:18
489 查看
CCSprite大家都知道,但是加上后面那一串又变成了神马呢?
我们可以首先到官方的API文档网站查一下,如下:
http://www.cocos2d-swift.org/docs/api/Classes/CCSprite9Slice.html
结果人家说的很清楚:
大意是CCSprite9Slice将在9个方格中渲染图片,除了中间的方格可能会根据情况发生拉伸变形以外,其他8个外围的方格中的内容将保持不会拉伸。
那么它又有什么用呢?其实在SpriteBuilder的slider和按钮控件都在内部使用了CCSprite9Slice对象;这样当你指定的图片不符合slider或button的长度要求时,拉伸或缩小的结果不至于导致图片看起来很奇怪。
我们可以首先到官方的API文档网站查一下,如下:
http://www.cocos2d-swift.org/docs/api/Classes/CCSprite9Slice.html
结果人家说的很清楚:
CCSprite9Slice will render an image in nine quads, keeping the margins fixed and stretching the center quad to fit the content size. The effect is that the image’s borders will remain unstretched while the center stretches.
大意是CCSprite9Slice将在9个方格中渲染图片,除了中间的方格可能会根据情况发生拉伸变形以外,其他8个外围的方格中的内容将保持不会拉伸。
那么它又有什么用呢?其实在SpriteBuilder的slider和按钮控件都在内部使用了CCSprite9Slice对象;这样当你指定的图片不符合slider或button的长度要求时,拉伸或缩小的结果不至于导致图片看起来很奇怪。
相关文章推荐
- getRequestDispatcher 和sendRedirect区别
- iOS-UICollectionView自定义布局
- android AlertDialog.Builder(Context context)换行
- iOS绘图系统UIKit与Core Graphics
- iOS绘图系统UIKit与Core Graphics
- 蓝牙服务 UUID
- 处理【Fatal error: Can't use function return value in write context 】的情况之《empty的解析》
- 在非Activity(非主线程)中更新UI的办法:(二)Handler+接口回调
- uCGUI学习笔记之显示文本
- 给UITextView增加链接
- 并发队列ConcurrentLinkedQueue和阻塞队列LinkedBlockingQueue用法
- 25-id to load is required for loading
- Android UI适配研究
- android中build过程
- Joblogs——ContentValues的使用
- UISwitch开关控件属性介绍以及获取开关状态并做出响应
- Android UI开发
- Leetcode82: Unique Binary Search Trees
- 关于UIBezierPath的使用
- EasyUI 格式化列