cocos2dx rect着色(cocos2d-x 和cocos2d 中CCRectContainsPoint的不同)

:暂无数据 2026-06-26 12:50:01 1

cocos2dx rect着色(cocos2d-x 和cocos2d 中CCRectContainsPoint的不同)

大家好,cocos2dx rect着色相信很多的网友都不是很明白,包括cocos2d-x 和cocos2d 中CCRectContainsPoint的不同也是一样,不过没有关系,接下来就来为大家分享关于cocos2dx rect着色和cocos2d-x 和cocos2d 中CCRectContainsPoint的不同的一些知识点,大家可以关注收藏,免得下次来找不到哦,下面我们开始吧!

本文目录

cocos2d-x 和cocos2d 中CCRectContainsPoint的不同

cocos2d是OC写的,cocos2dx是c++写的
cocos2d只能在ios下运行,cocos2dx是跨平台的,ios和android平台都可以运行
cocos2d是外国人搞的,cocos2dx是中国人搞的。
cocos2dx是cocos2d的C++写法,但是游戏架构是一样的,都包含了精灵,导演,场景,动作等概念,他们是一脉相承的东西。你可以直接研究cocos2dx,没有什么障碍。虽然是有了cocos2d才有的cocos2dx,但是cocos2dx包含了cocos2d的主要思想,因此可以直接研究cocos2dx。

cocos2dx精灵帧加载出问题

先CCTexture2D* EntityTexture=CCTextureCache::sharedTextureCache()-》addImage(addr);
再frame=CCSpriteFrame::createWithTexture(EntityTexture,cocos2d::CCRectMake(0,0,x,y));
加载资源的问题一般都会在输出中有错误提示的

关于cocos2d中的intersectsRect问题

你自己选中以后,按F12 ,追踪进去看一下,他不是Layer也是sprite ,就相当于是一个矩形检测是否碰撞

cocos2dx怎么得到一个指定layer

--创建一个touch的半透明layer
--priority : touch 权限级别,默认为-1024
--touchRect: 在touchRect 区域会放行touch事件 若touchRect = nil 则全屏吃touch
--touchCallback: 屏蔽层touch 回调
function createMaskLayer( priority,touchRect ,touchCallback, layerOpacity,highRect)
local layer = CCLayer:create()
layer:setPosition(ccp(0, 0))
layer:setAnchorPoint(ccp(0, 0))
layer:setTouchEnabled(true)
layer:setTouchPriority(priority or -1024)
layer:registerScriptTouchHandler(function ( eventType,x,y )
if(eventType == "began") then
if(touchRect == nil) then
if(touchCallback ~= nil) then
touchCallback()
end
return true
else
if(touchRect:containsPoint(ccp(x,y))) then
return false
else
if(touchCallback ~= nil) then
touchCallback()
end
return true
end
end
end
print(eventType)
end,false, priority or -1024, true)
local gw,gh = g_winSize.width, g_winSize.height
if(touchRect == nil) then
local layerColor = CCLayerColor:create(ccc4(0,0,0,layerOpacity or 150),gw,gh)
layerColor:setPosition(ccp(0,0))
layerColor:setAnchorPoint(ccp(0,0))
layer:addChild(layerColor)
return layer
else
local ox,oy,ow,oh = touchRect.origin.x, touchRect.origin.y, touchRect.size.width, touchRect.size.height
local layerColor = CCLayerColor:create(ccc4(0, 0, 0, layerOpacity or 150 ), gw, gh)
local clipNode = CCClippingNode:create();
clipNode:setInverted(true)
clipNode:addChild(layerColor)
local stencilNode = CCNode:create()
-- stencilNode:retain()
local node = CCScale9Sprite:create("bg.png");
node:setContentSize(CCSizeMake(ow, oh))
node:setAnchorPoint(ccp(0, 0))
node:setPosition(ccp(ox, oy))
stencilNode:addChild(node)
if(highRect ~= nil) then
local highNode = CCScale9Sprite:create("bg.png");
highNode:setContentSize(CCSizeMake(highRect.size.width, highRect.size.height))
highNode:setAnchorPoint(ccp(0, 0))
highNode:setPosition(ccp(highRect.origin.x, highRect.origin.y))
stencilNode:addChild(highNode)
end
clipNode:setStencil(stencilNode)
clipNode:setAlphaThreshold(0.5)
layer:addChild(clipNode)
end
return layer
end

cocos2dx怎么过滤掉spritesheet的背景色

Here’s an explanation of the keys.
frame
The sprite location within the sprite-sheet as position and size values.
offset
Most of the current texture packing tools remove transparent areas of the image before they pack it. Imagine you got a sprite with the size of 100x100, but on the left and right there are 4 columns of totally transparent pixels. The packing tool will remove these to save space, but store offset andsourceSize, so that your sprite will be 100x100 pixels in your game. Note that the offset is always relative to the center of the sprite (comparing the center of the cropped and the center of the original sprite).
rotated
Whether or not the sprite has been rotated within the sprite-sheet (if this is true, the sprite is rotated 90 degrees clockwise).
sourceColorRect
The rectangle with actual color information inside your source sprite. If you take the 100x100 image described above (with 4px transparent pixels on the left and on the right), the sourceColorRect will be {{4,0},{92,100}}
sourceSize
This is the size of the original sprite (beware that some texture-packers can add padding to this if you chose to).
个人理解:
sourceSize:
动画的尺寸,如果一个动画有很多帧的话,所有帧的sourceSize是不变的,基本上可以理解为这么多帧中最大显示范围的那个尺寸
frame:
标示这一帧的截图,在整个spritesheet中的位置和尺寸
offset:
标示这个截图的中心点,和整个动画的中心点(以sourceSize这个方形的中心点),的xy差值,记得这个是以cocos2d的坐标系为准的,y轴向上为正
sourceColorRect
这个截图在sourceSize这个方形的位置和尺寸(均以左上角来算)
值得注意的是:
搜索一下realTextureFileName和textureFileName,这两个key下面的string属性必须是对应spritesheet的文件名!有时候改了plist和png的文件名,忘记改这俩个值,则会加载不了图片

关于本次cocos2dx rect着色和cocos2d-x 和cocos2d 中CCRectContainsPoint的不同的问题分享到这里就结束了,如果解决了您的问题,我们非常高兴。

cocos2dx rect着色(cocos2d-x 和cocos2d 中CCRectContainsPoint的不同)

本文编辑:admin

更多文章:


二进制转换十进制函数(二进制如何转换成十进制数)

二进制转换十进制函数(二进制如何转换成十进制数)

这篇文章给大家聊聊关于二进制转换十进制函数,以及二进制如何转换成十进制数对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。

2026年9月22日 01:30

大一程序设计基础题库(c语言程序设计试题)

大一程序设计基础题库(c语言程序设计试题)

今天给各位分享c语言程序设计试题的知识,其中也会对c语言程序设计试题进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

2026年9月22日 01:00

方舟生存进化新物种图鉴中英文对照图鉴 庞马资料图鉴 庞马(Equus magnus)?植物大战僵尸英文版图鉴

方舟生存进化新物种图鉴中英文对照图鉴 庞马资料图鉴 庞马(Equus magnus)?植物大战僵尸英文版图鉴

各位老铁们,大家好,今天由我来为大家分享图鉴英文,以及方舟生存进化新物种图鉴中英文对照图鉴 庞马资料图鉴 庞马(Equus magnus)的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,

2026年9月22日 00:10

servlet容器配置(web.xml不包含哪些定义)

servlet容器配置(web.xml不包含哪些定义)

大家好,servlet容器配置相信很多的网友都不是很明白,包括web.xml不包含哪些定义也是一样,不过没有关系,接下来就来为大家分享关于servlet容器配置和web.xml不包含哪些定义的一些知识点,大家可以关注收藏,免得下次来找不到哦

2026年9月21日 22:40

全球著名软件公司?oracle究竟是什么软件

全球著名软件公司?oracle究竟是什么软件

各位老铁们,大家好,今天由我来为大家分享软件公司,以及全球著名软件公司的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!

2026年9月21日 18:50

html document对象(载入浏览器的html文档都会成为document的对象吗)

html document对象(载入浏览器的html文档都会成为document的对象吗)

其实html document对象的问题并不复杂,但是又很多的朋友都不太了解载入浏览器的html文档都会成为document的对象吗,因此呢,今天小编就来为大家分享html document对象的一些知识,希望可以帮助到大家,下面我们一起来

2026年9月21日 16:00

安装包怎样下载mysql(如何在官网上下载可安装版的MySQL数据库)

安装包怎样下载mysql(如何在官网上下载可安装版的MySQL数据库)

大家好,安装包怎样下载mysql相信很多的网友都不是很明白,包括如何在官网上下载可安装版的MySQL数据库也是一样,不过没有关系,接下来就来为大家分享关于安装包怎样下载mysql和如何在官网上下载可安装版的MySQL数据库的一些知识点,大家

2026年9月21日 15:30

威廉尖叫音效在线(渴求《勇敢的心》的配乐a gift of a thistle下载)

威廉尖叫音效在线(渴求《勇敢的心》的配乐a gift of a thistle下载)

各位老铁们,大家好,今天由我来为大家分享威廉尖叫音效在线,以及渴求《勇敢的心》的配乐a gift of a thistle下载的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈

2026年9月21日 15:20

wordpress建站教程视频(WordPress建站的基本流程)

wordpress建站教程视频(WordPress建站的基本流程)

这篇文章给大家聊聊关于wordpress建站教程视频,以及WordPress建站的基本流程对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。

2026年9月21日 14:00

fortune短语搭配(fortune什么意思)

fortune短语搭配(fortune什么意思)

“fortune短语搭配”相关信息最新大全有哪些,这是大家都非常关心的,接下来就一起看看fortune短语搭配(fortune什么意思)!

2026年9月21日 13:50

最近更新

广东网站建设怎么一步步完成?
2026-09-22 02:12:32 浏览:0
营口seo推广如何引流新公司
2026-09-22 02:11:58 浏览:0
环保网站建设如何选择合适的CMS系统
2026-09-22 02:11:33 浏览:0
长沙做网站需要哪些资料?
2026-09-22 02:10:56 浏览:0
遵义企业网站定制开发怎么做才好?
2026-09-22 02:10:33 浏览:0
江西搜狗seo优化怎么入门
2026-09-22 02:10:26 浏览:0
热门文章

wait for you杨和苏(大家听下(wait for you)这首英文歌的开头那段音乐)
2026-06-13 16:20:04 浏览:22
刷关键字排名怎么操作最有效?
2026-09-14 20:02:13 浏览:13
oppo a9拆机教程(oppoa9拆机教程)
2026-06-13 10:40:02 浏览:12
标签列表