cocos2d-x getVisibleSize、getContentSize、getWinSize函数
来源:互联网 发布:win7精仿mac系统下载 编辑:程序博客网 时间:2024/05/23 00:34
在cocos2d-x里CCNode对象有缩放的方法setScaleX和setScaleY。所以在获取对象大小的时候必须根据情况明确指定获取对象原始大小,还是缩放后的大小。
cocos2d::Size size1 = cocos2d::CCDirector::getInstance()->getWinSize();float scaleX=size1.width/768;float scaleY=size1.height/1024;Sprite *sp1=Sprite::create("01.png"); sp1->setScaleX(scaleX); sp1->setScaleY(scaleY); this->addChild(sp1);
getVisibleSize:获得可视区域的大小,若是DesignResolutionSize跟屏幕尺寸一样大,则getVisibleSize便是getWinSize。
getVisibleOrigin:获得可视区域的出发点坐标,在处理相对位置时,确保节点在不同分辨率下的位置一致。
getContentSize函数来获得节点原始的大小。只是逻辑尺寸,不是像素
假如使用一张图创建了一个精灵,图片的大小120*120,缩放先后通过getContentSize获取的大小不变,
在精灵进行缩放后,你的精灵图片变化了,这时候你见到的是可见的visibleSize,而getContentSize,是获取它实际的图片
getContentSizeInPixels获得的是像素点大小
P.S.像素点和逻辑点关系:逻辑点大小 = 像素大小/contentScaleFactor.
//像素:图像由一个个点组成,这个点叫做像素
0 0
- cocos2d-x getVisibleSize、getContentSize、getWinSize函数
- cocos2d.x getVisibleSize 和 getContentSize 和 getWinSize 区别
- getVisibleSize 和 getContentSize 和 getWinSize
- getVisibleSize 和 getContentSize 和 getWinSize
- getVisibleSize 和 getContentSize 和 getWinSize
- getVisibleSize 和 getContentSize 和 getWinSize
- getVisibleSize 和 getContentSize 和 getWinSize
- getVisibleSize 和 getContentSize 和 getWinSize 相关区别
- Cocos2d-x之getVisibleSize,getContentSize,boundingBox,getContentSizeInPixels,convertToGL,convertToUI
- Cocos2d-x之getVisibleSize,getContentSize,boundingBox,getContentSizeInPixels,convertToGL,convertToUI
- Cocos2d-x之getVisibleSize,getContentSize,boundingBox,getContentSizeInPixels,convertToGL,convertToUI
- Cocos2d-x之getVisibleSize,getContentSize,boundingBox,getContentSizeInPixels,convertToGL,convertToUI
- getwinSize与getVisibleSize区别
- cocos2d-x 中 getContentSize
- cocos2d-x3.2中的getVisibleSize,getContentSize,boundingBox,getContentSizeInPixels,convertToGL,convertTo
- cocos2d-x getBoundingBox getContentSize getTextureRect 解释
- cocos2d-x getBoundingBox getContentSize getTextureRect 解释
- cocos2d-x getBoundingBox getContentSize getTextureRect 解释
- model中的index()函数
- ios8 UITableView设置 setSeparatorInset:UIEdgeInsetsZero不起作用的解决办法
- String直接赋字符串和new String的区别
- 外语好的人,工资就是比你高,不服来辩
- 索引缓存优点和使用
- cocos2d-x getVisibleSize、getContentSize、getWinSize函数
- Android流量统计TrafficStats类的使用
- 收集android上开源的酷炫的交互动画和视觉效果:Interactive-animation
- 数据结构第一题线性表的各种操作SqList
- 梯度与微分
- model中的layoutChanged ()信号 通知视图更新界面
- C++实验2-项目一
- 浪涌防护器件的应用
- 自定义一个图片shape