﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-demibug</title><link>http://www.blogjava.net/demibug/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 12 Apr 2026 06:10:44 GMT</lastBuildDate><pubDate>Sun, 12 Apr 2026 06:10:44 GMT</pubDate><ttl>60</ttl><item><title>PS  如何去除光晕的黑色背景</title><link>http://www.blogjava.net/demibug/archive/2013/03/20/396721.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Wed, 20 Mar 2013 04:19:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/03/20/396721.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/396721.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/03/20/396721.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/396721.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/396721.html</trackback:ping><description><![CDATA[<pre id="answer-content-675599077" accuse="aContent"  mb-10"="" style="margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace; white-space: pre-wrap; word-wrap: break-word; color: #333333; line-height: 24px; background-color: #ffffff;">背景色是纯黑的？<br />转到通道面板，按住Ctrl+Shift键，依次点击红绿蓝三个通道，得到光晕的选区。选中图层，按下Ctrl+J键，得到光晕图层。隐藏背景图层。此时的光晕包含有少量透明的黑底，因为背景是黑色，当把透明的光晕图层放到别的图层上时，将混合模式改为&#8220;滤色&#8221;即可达到屏蔽黑色背景的目的。<br />或者用背景橡皮擦，但是效果不是很好。</pre><img src ="http://www.blogjava.net/demibug/aggbug/396721.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-03-20 12:19 <a href="http://www.blogjava.net/demibug/archive/2013/03/20/396721.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>cocos2d-x 2.0版本 自适应屏幕分辨率</title><link>http://www.blogjava.net/demibug/archive/2013/03/13/396355.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Tue, 12 Mar 2013 17:25:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/03/13/396355.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/396355.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/03/13/396355.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/396355.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/396355.html</trackback:ping><description><![CDATA[<p style="color: #333333; background-color: #ffffff; margin-top: 0px; margin-bottom: 0px; padding: 5px 10px; line-height: 1.8; text-indent: 28px; font-family: Tahoma, Geneva, sans-serif;">我使用的版本是cocos2d-2.0-x-2.0.4，cocos2dx-2.0版本对多分辨率适配提供了很好的支持，使用起来比1.0版本要简单些，1.0版本的适配可以参考<a href="http://codingnow.cn/android/954.html" target="_blank" style="color: #950000; text-decoration: initial;">这篇博文</a>。<br />1. 做2.0版本的适配首先需要了解下面这些知识。<br /><span style="color: #993300;"><strong>(1)适配策略</strong></span><br />2.0版本提供了三种适配策略：<br /><span style="color: #993300;">kResolutionNoBorder：</span>超出屏幕的部分会被裁剪，两侧没有黑边，铺满屏幕，按图片原始比例显示，图片不变形。<br /><span style="color: #993300;">kResolutionShowAll：</span>整个游戏界面是可见的，会按原始比例进行缩放，图片不变形，但两侧可能会留有黑边，不铺满屏幕。<br /><span style="color: #993300;">kResolutionExactFit：</span>整个游戏界面是可见的，图片可能会进行拉伸或者压缩处理，铺满屏幕，图片会变形。<br />可以根据自己的要求选择。<br /><strong><span style="color: #993300;">(2)VisibleSize和VisibleOrigin</span></strong><br />getVisibleSize：表示获得视口(可视区域)的大小，如果DesignResolutionSize跟屏幕尺寸一样大，则getVisibleSize等于getWinSize。<br />getVisibleOrigin：表示可视区域的起点坐标，这在处理相对位置的时候非常有用，确保节点在不同分辨率下的位置一致。<br /><strong><span style="color: #993300;">(3)DesignResolutionSize</span></strong><br />DesignResolutionSize是一个比较重要的概念，其实2.0版本的适配跟1.0版本原理差不多，都是按比例进行缩放。这个DesignResolutionSize表示设计方案，就是你的游戏完美支持的分辨率方案，一般根据图片资源的尺寸来定，自适配时会按照这个分辨率计算出缩放因子。因此，这个值也应该是动态的，如果是横屏游戏则高度肯定是铺满屏幕的，宽度也要尽可能的铺满屏幕，因此应该选择宽高比最大的作为设计分辨率，下面的demo会给出使用方法。<br /><strong><span style="color: #993300;">(4)设置相对位置</span></strong><br />在游戏中使用相对位置设置坐标的好处是显而易见的，这样就不需要为每个分辨率都定义一套坐标了。首先得定义一些参考点，引擎的TestCpp例子中就提供了一种方法，以屏幕上可视区域的9个点作为参考点，相当于在该矩形内写一个米字，这9个点分别是：左上、左、左下、下、右下、右、右上、上、中心。</p><p style="color: #333333; background-color: #ffffff; margin-top: 0px; margin-bottom: 0px; padding: 5px 10px; line-height: 1.8; text-indent: 28px; font-family: Tahoma, Geneva, sans-serif;">2. 下面来实现一个简单的demo，首先创建一个win32工程，这个就不详述了。<br />(1)创建一个AppMacros.h文件，定义了一些宏，源码如下：</p><p style="color: #333333; background-color: #ffffff; margin-top: 0px; margin-bottom: 0px; padding: 5px 10px; line-height: 1.8; text-indent: 28px; font-family: Tahoma, Geneva, sans-serif;"></p><div bg_cpp"="" style="width: 687.046875px; color: #333333; line-height: 26px;"><div><div><strong>[cpp]</strong>&nbsp;<a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 558px; top: 1113px; width: 18px; height: 18px; z-index: 99;"></div><div style="position: absolute; left: 558px; top: 1113px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_1" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;">#ifndef&nbsp;__APPMACROS_H__&nbsp;&nbsp;</li><li style="line-height: 18px;">#define&nbsp;__APPMACROS_H__&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">#include&nbsp;"cocos2d.h"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">typedef&nbsp;struct&nbsp;tagResource&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;cocos2d::CCSize&nbsp;size;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2e8b57; font-weight: bold;">char</span>&nbsp;directory[100];&nbsp;&nbsp;</li><li style="line-height: 18px;">}Resource;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">//可用的资源尺寸&nbsp;&nbsp;</li><li style="line-height: 18px;">static&nbsp;Resource&nbsp;smallResource&nbsp;&nbsp;=&nbsp;&nbsp;{&nbsp;cocos2d::CCSizeMake(480,&nbsp;320),&nbsp;&nbsp;&nbsp;"iphone"&nbsp;};&nbsp;&nbsp;</li><li style="line-height: 18px;">static&nbsp;Resource&nbsp;mediumResource&nbsp;=&nbsp;&nbsp;{&nbsp;cocos2d::CCSizeMake(1024,&nbsp;768),&nbsp;&nbsp;"ipad"&nbsp;&nbsp;&nbsp;};&nbsp;&nbsp;</li><li style="line-height: 18px;">static&nbsp;Resource&nbsp;largeResource&nbsp;&nbsp;=&nbsp;&nbsp;{&nbsp;cocos2d::CCSizeMake(2048,&nbsp;1536),&nbsp;"ipadhd"&nbsp;};&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">//设计方案&nbsp;&nbsp;</li><li style="line-height: 18px;">static&nbsp;cocos2d::CCSize&nbsp;smallDesignResolutionSize&nbsp;=&nbsp;cocos2d::CCSizeMake(480.0f,&nbsp;320.0f);&nbsp;&nbsp;</li><li style="line-height: 18px;">static&nbsp;cocos2d::CCSize&nbsp;mediumDesignResolutionSize&nbsp;=&nbsp;cocos2d::CCSizeMake(1024.0f,&nbsp;768.0f);&nbsp;&nbsp;</li><li style="line-height: 18px;">static&nbsp;cocos2d::CCSize&nbsp;largeDesignResolutionSize&nbsp;=&nbsp;cocos2d::CCSizeMake(2048.0f,&nbsp;1536.0f);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">//缩放因子，主要给文字标签使用&nbsp;&nbsp;</li><li style="line-height: 18px;">#define&nbsp;SCALE_FACTOR&nbsp;&nbsp;(cocos2d::CCEGLView::sharedOpenGLView()-&gt;getDesignResolutionSize().width&nbsp;/&nbsp;smallResource.size.width)&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">#endif&nbsp;&nbsp;</li></ol></div><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">(2)接下来修改AppDelegate.cpp文件的applicationDidFinishLaunching函数，添加以下代码：</span><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p><p style="color: #333333; background-color: #ffffff; margin-top: 0px; margin-bottom: 0px; padding: 5px 10px; line-height: 1.8; text-indent: 28px; font-family: Tahoma, Geneva, sans-serif;"></p><div bg_cpp"="" style="width: 687.046875px; color: #333333; line-height: 26px;"><div><div><strong>[cpp]</strong>&nbsp;<a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 558px; top: 1715px; width: 18px; height: 18px; z-index: 99;"></div><div style="position: absolute; left: 558px; top: 1715px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_2" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;"><span style="color: #2e8b57; font-weight: bold;">bool</span>&nbsp;AppDelegate::applicationDidFinishLaunching()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;initialize&nbsp;director&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCDirector&nbsp;*pDirector&nbsp;=&nbsp;CCDirector::sharedDirector();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCEGLView&nbsp;*pEGLView&nbsp;=&nbsp;CCEGLView::sharedOpenGLView();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pDirector-&gt;setOpenGLView(pEGLView);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCSize&nbsp;frameSize&nbsp;=&nbsp;pEGLView-&gt;getFrameSize();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2e8b57; font-weight: bold;">float</span>&nbsp;ratio&nbsp;=&nbsp;frameSize.width&nbsp;/&nbsp;frameSize.height;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2e8b57; font-weight: bold;">float</span>&nbsp;ratio1&nbsp;=&nbsp;largeDesignResolutionSize.width&nbsp;/&nbsp;largeDesignResolutionSize.height;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2e8b57; font-weight: bold;">float</span>&nbsp;ratio2&nbsp;=&nbsp;mediumDesignResolutionSize.width&nbsp;/&nbsp;mediumDesignResolutionSize.height;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2e8b57; font-weight: bold;">float</span>&nbsp;ratio3&nbsp;=&nbsp;smallDesignResolutionSize.width&nbsp;/&nbsp;smallDesignResolutionSize.height;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2e8b57; font-weight: bold;">float</span>&nbsp;d1&nbsp;=&nbsp;abs(ratio&nbsp;-&nbsp;ratio1);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2e8b57; font-weight: bold;">float</span>&nbsp;d2&nbsp;=&nbsp;abs(ratio&nbsp;-&nbsp;ratio2);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2e8b57; font-weight: bold;">float</span>&nbsp;d3&nbsp;=&nbsp;abs(ratio&nbsp;-&nbsp;ratio3);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;std::map&lt;<span style="color: #2e8b57; font-weight: bold;">float</span>,&nbsp;CCSize&gt;&nbsp;designSize;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;designSize[d1]&nbsp;=&nbsp;largeDesignResolutionSize;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;designSize[d2]&nbsp;=&nbsp;mediumDesignResolutionSize;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;designSize[d3]&nbsp;=&nbsp;smallDesignResolutionSize;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;std::map&lt;<span style="color: #2e8b57; font-weight: bold;">float</span>,&nbsp;CCSize&gt;::reverse_iterator&nbsp;iter&nbsp;=&nbsp;designSize.rbegin();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//得到key最大的，因此我这里是横屏，所以以高度为基准，为了确保缩放后宽度能全屏，所以选取宽高比最大的为设计方案&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCSize&nbsp;designResolutionSize&nbsp;=&nbsp;iter-&gt;second;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//pEGLView-&gt;setDesignResolutionSize(designResolutionSize.width,&nbsp;designResolutionSize.height,&nbsp;kResolutionNoBorder);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pEGLView-&gt;setDesignResolutionSize(designResolutionSize.width,&nbsp;designResolutionSize.height,&nbsp;kResolutionShowAll);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//pEGLView-&gt;setDesignResolutionSize(designResolutionSize.width,&nbsp;designResolutionSize.height,&nbsp;kResolutionExactFit);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(frameSize.height&nbsp;&gt;&nbsp;mediumResource.size.height)&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CCFileUtils::sharedFileUtils()-&gt;setResourceDirectory(largeResource.directory);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDirector-&gt;setContentScaleFactor(largeResource.size.height/designResolutionSize.height);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(frameSize.height&nbsp;&gt;&nbsp;smallResource.size.height)&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CCFileUtils::sharedFileUtils()-&gt;setResourceDirectory(mediumResource.directory);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDirector-&gt;setContentScaleFactor(mediumResource.size.height/designResolutionSize.height);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CCFileUtils::sharedFileUtils()-&gt;setResourceDirectory(smallResource.directory);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDirector-&gt;setContentScaleFactor(smallResource.size.height/designResolutionSize.height);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pDirector-&gt;setDisplayStats(true);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pDirector-&gt;setAnimationInterval(1.0&nbsp;/&nbsp;60);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCScene&nbsp;*pScene&nbsp;=&nbsp;HelloWorld::scene();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pDirector-&gt;runWithScene(pScene);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;true;&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li></ol></div><br style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;" /><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">(3)创建VisibleRect.h和VisibleRect.cpp文件，封装了获取那9个点坐标的函数，比较简单。代码如下：</span><br style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;" /><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">VisibleRect.h</span><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p><p style="color: #333333; background-color: #ffffff; margin-top: 0px; margin-bottom: 0px; padding: 5px 10px; line-height: 1.8; text-indent: 28px; font-family: Tahoma, Geneva, sans-serif;"></p><div bg_cpp"="" style="width: 687.046875px; color: #333333; line-height: 26px;"><div><div><strong>[cpp]</strong>&nbsp;<a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 558px; top: 2980px; width: 18px; height: 18px; z-index: 99;"></div><div style="position: absolute; left: 558px; top: 2980px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_3" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;">#ifndef&nbsp;__VISIBLERECT_H__&nbsp;&nbsp;</li><li style="line-height: 18px;">#define&nbsp;__VISIBLERECT_H__&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">#include&nbsp;"cocos2d.h"&nbsp;&nbsp;</li><li style="line-height: 18px;">USING_NS_CC;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">class&nbsp;VisibleRect&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">public:&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCRect&nbsp;getVisibleRect();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;left();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;right();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;top();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;bottom();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;center();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;leftTop();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;rightTop();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;leftBottom();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCPoint&nbsp;rightBottom();&nbsp;&nbsp;</li><li style="line-height: 18px;">private:&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;void&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;CCRect&nbsp;s_visibleRect;&nbsp;&nbsp;</li><li style="line-height: 18px;">};&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">#endif&nbsp;&nbsp;</li></ol></div><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">VisibleRect.cpp</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p><div bg_cpp"="" style="width: 687.046875px; color: #333333; line-height: 26px;"><div><div><strong>[cpp]</strong>&nbsp;<a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 558px; top: 3542px; width: 18px; height: 18px; z-index: 99;"></div><div style="position: absolute; left: 558px; top: 3542px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_4" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;">#include&nbsp;"VisibleRect.h"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCRect&nbsp;VisibleRect::s_visibleRect;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">void&nbsp;VisibleRect::lazyInit()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(s_visibleRect.size.width&nbsp;==&nbsp;0.0f&nbsp;&amp;&amp;&nbsp;s_visibleRect.size.height&nbsp;==&nbsp;0.0f)&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CCEGLView*&nbsp;pEGLView&nbsp;=&nbsp;CCEGLView::sharedOpenGLView();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s_visibleRect.origin&nbsp;=&nbsp;pEGLView-&gt;getVisibleOrigin();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s_visibleRect.size&nbsp;=&nbsp;pEGLView-&gt;getVisibleSize();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCRect&nbsp;VisibleRect::getVisibleRect()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;CCRectMake(s_visibleRect.origin.x,&nbsp;s_visibleRect.origin.y,&nbsp;s_visibleRect.size.width,&nbsp;s_visibleRect.size.height);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::left()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;ccp(s_visibleRect.origin.x,&nbsp;s_visibleRect.origin.y&nbsp;+&nbsp;s_visibleRect.size.height/2);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::right()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;ccp(s_visibleRect.origin.x+s_visibleRect.size.width,&nbsp;s_visibleRect.origin.y&nbsp;+&nbsp;s_visibleRect.size.height/2);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::top()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;ccp(s_visibleRect.origin.x&nbsp;+&nbsp;s_visibleRect.size.width/2,&nbsp;s_visibleRect.origin.y&nbsp;+&nbsp;s_visibleRect.size.height);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::bottom()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;ccp(s_visibleRect.origin.x&nbsp;+&nbsp;s_visibleRect.size.width/2,&nbsp;s_visibleRect.origin.y);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::center()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;ccp(s_visibleRect.origin.x&nbsp;+&nbsp;s_visibleRect.size.width/2,&nbsp;s_visibleRect.origin.y&nbsp;+&nbsp;s_visibleRect.size.height/2);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::leftTop()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;ccp(s_visibleRect.origin.x,&nbsp;s_visibleRect.origin.y&nbsp;+&nbsp;s_visibleRect.size.height);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::rightTop()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;ccp(s_visibleRect.origin.x&nbsp;+&nbsp;s_visibleRect.size.width,&nbsp;s_visibleRect.origin.y&nbsp;+&nbsp;s_visibleRect.size.height);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::leftBottom()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;s_visibleRect.origin;&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCPoint&nbsp;VisibleRect::rightBottom()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;lazyInit();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;ccp(s_visibleRect.origin.x&nbsp;+&nbsp;s_visibleRect.size.width,&nbsp;s_visibleRect.origin.y);&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li></ol></div><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">(4)修改HelloWorldScene.cpp的init函数，使用相对位置设置坐标。</span><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p><div bg_cpp"="" style="width: 687.046875px; color: #333333; line-height: 26px;"><div><div><strong>[cpp]</strong>&nbsp;<a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 558px; top: 4966px; width: 18px; height: 18px; z-index: 99;"></div><div style="position: absolute; left: 558px; top: 4966px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_5" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_5" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=5&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;"><span style="color: #2e8b57; font-weight: bold;">bool</span>&nbsp;HelloWorld::init()&nbsp;&nbsp;</li><li style="line-height: 18px;">{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;!CCLayer::init()&nbsp;)&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;false;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCMenuItemImage&nbsp;*pCloseItem&nbsp;=&nbsp;CCMenuItemImage::create(&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"CloseNormal.png",&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"CloseSelected.png",&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this,&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;menu_selector(HelloWorld::menuCloseCallback));&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pCloseItem-&gt;setPosition(ccpAdd(VisibleRect::rightBottom(),&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ccp(-pCloseItem-&gt;getContentSize().width/2,&nbsp;pCloseItem-&gt;getContentSize().height/2)));&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCMenu*&nbsp;pMenu&nbsp;=&nbsp;CCMenu::create(pCloseItem,&nbsp;NULL);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pMenu-&gt;setPosition(CCPointZero);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;addChild(pMenu,&nbsp;1);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCLabelTTF*&nbsp;pLabel&nbsp;=&nbsp;CCLabelTTF::create("Hello&nbsp;World",&nbsp;"Arial",&nbsp;SCALE_FACTOR&nbsp;*&nbsp;24);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pLabel-&gt;setPosition(ccpAdd(VisibleRect::top(),&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ccp(0,&nbsp;-pLabel-&gt;getContentSize().height)));&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;addChild(pLabel,&nbsp;1);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCSprite*&nbsp;pSprite&nbsp;=&nbsp;CCSprite::create("HelloWorld.png");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pSprite-&gt;setPosition(VisibleRect::center());&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;addChild(pSprite,&nbsp;0);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;CCSprite&nbsp;*pLogoSprite&nbsp;=&nbsp;CCSprite::create("icon.png");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pLogoSprite-&gt;setAnchorPoint(&nbsp;ccp(0,&nbsp;0.5)&nbsp;);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;pLogoSprite-&gt;setPosition(ccpAdd(VisibleRect::left(),&nbsp;ccp(50,&nbsp;0)));&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;addChild(pLogoSprite,&nbsp;0);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;true;&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li></ol></div><br style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;" /><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">(5)创建窗口，main.cpp的主要内容：</span><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p><div bg_cpp"="" style="width: 687.046875px; color: #333333; line-height: 26px;"><div><div><strong>[cpp]</strong>&nbsp;<a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/gg137608987/article/details/8302699#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 558px; top: 5734px; width: 18px; height: 18px; z-index: 99;"></div><div style="position: absolute; left: 558px; top: 5734px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_6" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_6" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=6&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;">AppDelegate&nbsp;app;&nbsp;&nbsp;</li><li style="line-height: 18px;">CCEGLView*&nbsp;eglView&nbsp;=&nbsp;CCEGLView::sharedOpenGLView();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//eglView-&gt;setFrameSize(2048,&nbsp;1536);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//eglView-&gt;setFrameSize(480,&nbsp;320);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//eglView-&gt;setFrameSize(800,&nbsp;480);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//eglView-&gt;setFrameSize(1024,&nbsp;768);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//eglView-&gt;setFrameSize(1280,&nbsp;800);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;eglView-&gt;setFrameSize(1280,&nbsp;768);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//eglView-&gt;setFrameSize(960,&nbsp;640);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;eglView-&gt;setFrameZoomFactor(0.5f);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;"><span style="color: #2e8b57; font-weight: bold;">int</span>&nbsp;ret&nbsp;=&nbsp;CCApplication::sharedApplication()-&gt;run();&nbsp;&nbsp;</li></ol></div><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">OK，到此为止，代码部分已经完成了，下面看看在各种分辨率和不同策略下的效果图：</span><br style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;" /><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">1. kResolutionShowAll策略</span><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">：</span><br style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;" /><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">(1)</span><span style="background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px; color: #993300;">2048&#215;1536</span><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;"><span style="color: #993300;"><img src="http://codingnow.cn/wp-content/uploads/2012/12/20121204221330.png" alt="" style="border: none;" /><br /></span><br />(2)<span style="color: #993300;">1024&#215;768</span><br /></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;"><span style="color: #993300;"><img src="http://codingnow.cn/wp-content/uploads/2012/12/20121204221415.png" alt="" style="border: none;" /><br /></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;"><span style="color: #993300;">(3)480&#215;320<br /></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;"><span style="color: #993300;"><img src="http://codingnow.cn/wp-content/uploads/2012/12/20121204221454.png" alt="" style="border: none;" /><br /></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;"></span></p><span style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;">2. kResolutionExactFit策略</span><br style="color: #333333; background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;" /><span style="background-color: #ffffff; font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px; color: #993300;">1280&#215;768分辨率</span><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;"><span style="color: #993300;"><img src="http://codingnow.cn/wp-content/uploads/2012/12/20121204224333.png" alt="" style="border: none;" /><br /></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;"><span style="color: #993300;">3. kResolutionNoBorder策略<br />1280&#215;768分辨率<br /></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 25px; text-indent: 28px;"><span style="color: #993300;"><img src="http://codingnow.cn/wp-content/uploads/2012/12/20121204224410.png" alt="" style="border: none;" /></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 1.8; text-indent: 28px; color: #993300;">demo源码：http://download.csdn.net/detail/zhoujianghai/4847206</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: Tahoma, Geneva, sans-serif; line-height: 1.8; text-indent: 28px; color: #993300;">本文链接：http://codingnow.cn/cocos2d-x/975.html</span></p><img src ="http://www.blogjava.net/demibug/aggbug/396355.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-03-13 01:25 <a href="http://www.blogjava.net/demibug/archive/2013/03/13/396355.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>深入了解CCSprite</title><link>http://www.blogjava.net/demibug/archive/2013/03/11/396277.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Mon, 11 Mar 2013 03:05:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/03/11/396277.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/396277.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/03/11/396277.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/396277.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/396277.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 本章我们将深入了解精灵（Sprite）。我们可以通过很多方式用单个文件或者纹理贴图集（Texture Atlases）来生成精灵。我也会在本章介绍如何创建和播放精灵动画。&nbsp; 纹理贴图集是一张包含很多图片的纹理贴图（图片），通常用于存放单个角色动画的所有动画帧。不过它的作用不止于此。实际上你可以把任何图片放进同一张纹理贴图中。我们的目的是把尽可能多的图片放进同一张纹理贴图中，以达到节省空间...&nbsp;&nbsp;<a href='http://www.blogjava.net/demibug/archive/2013/03/11/396277.html'>阅读全文</a><img src ="http://www.blogjava.net/demibug/aggbug/396277.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-03-11 11:05 <a href="http://www.blogjava.net/demibug/archive/2013/03/11/396277.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CCsprite学习笔记</title><link>http://www.blogjava.net/demibug/archive/2013/03/11/396276.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Mon, 11 Mar 2013 03:04:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/03/11/396276.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/396276.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/03/11/396276.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/396276.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/396276.html</trackback:ping><description><![CDATA[<p style="margin: 0px; text-indent: 28px; padding: 5px 10px; line-height: 1.8; font-family: Tahoma, Geneva, sans-serif; background-color: #ffffff;">精灵是游戏中十分重要的组成部分，随处可见，如：游戏背景、NPC、人物、道具等。在cocos2d-x引擎中，只要是用图片展示的，基本上需要使用精灵类。<br /><span style="color: #800000;"><strong>1. 首先来了解一下跟精灵相关的几个类：</strong></span><br /><span style="color: #0000ff;">(1) CCTexture2D</span><br />可以把它看成一个纹理，它是cocos2d-x渲染图形的重要参数，用来贴图，因为cocos2d-x使用opengl es绘制2d图形的，它的尺寸是2的n次方。一般通过以下方式获得：</p><div style="font-family: Tahoma, Geneva, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;"><div id="highlighter_56571"  cpp"="" style="width: 686px; margin: 1em 0px !important; position: relative !important; overflow: auto !important; font-size: 1em !important;"><table border="0" cellpadding="0" cellspacing="0" style="width: 686px; border: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;"><tbody style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important;"><tr style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important;"><td style="border: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; color: #afafaf !important;"><div number1="" index0=""  alt2"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">1</div></td><td style="width: 656px; border: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important;"><div style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important;"><div number1="" index0=""  alt2"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code plain"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">CCTexture2D* cache = CCTextureCache::sharedTextureCache()-&gt;addImage(</code><code string"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: blue !important;">"hero.png"</code><code plain"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">);</code></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; text-indent: 28px; padding: 5px 10px; line-height: 1.8; font-family: Tahoma, Geneva, sans-serif; background-color: #ffffff;"><span style="color: #0000ff;">(2) CCSprite</span><br />这个就是精灵类，是CCNode的子类，它的内部封装了CCTexture2D(纹理)，可以通过下面几种方式初始化精灵对象。</p><div style="font-family: Tahoma, Geneva, sans-serif; font-size: 13px; line-height: normal; background-color: #ffffff;"><div id="highlighter_581655"  cpp"="" style="width: 686px; margin: 1em 0px !important; position: relative !important; overflow: auto !important; font-size: 1em !important;"><table border="0" cellpadding="0" cellspacing="0" style="width: 1015px; border: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;"><tbody style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important;"><tr style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important;"><td style="border: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; color: #afafaf !important;"><div number1="" index0=""  alt2"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">1</div><div number2="" index1=""  alt1"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">2</div><div number3="" index2=""  alt2"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">3</div><div number4="" index3=""  alt1"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">4</div><div number5="" index4=""  alt2"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">5</div><div number6="" index5=""  alt1"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">6</div><div number7="" index6=""  alt2"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">7</div><div number8="" index7=""  alt1"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">8</div><div number9="" index8=""  alt2"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">9</div><div number10="" index9=""  alt1"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">10</div><div number11="" index10=""  alt2"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">11</div><div number12="" index11=""  alt1"="" style="border-top-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #0099ff; border-bottom-color: #0099ff; border-left-color: #0099ff; padding-right: 0.5em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border-width: 0px 3px 0px 0px !important; border-right-style: solid !important; border-right-color: #6ce26c !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;">12</div></td><td style="width: 978px; border: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important;"><div style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important;"><div number1="" index0=""  alt2"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code comments"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: #008200 !important;">//CCTexture2D表示精灵包含的图片，范围是整张图片</code></div><div number2="" index1=""  alt1"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code keyword=""  bold"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: #006699 !important;">static</code> <code plain"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">CCSprite* spriteWithTexture(CCTexture2D *pTexture);</code></div><div number3="" index2=""  alt2"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code comments"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: #008200 !important;">//CCRect表示图片的指定范围，即从图片的指定矩形区域裁剪</code></div><div number4="" index3=""  alt1"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code keyword=""  bold"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: #006699 !important;">static</code> <code plain"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">CCSprite* spriteWithTexture(CCTexture2D *pTexture, </code><code keyword=""  bold"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: #006699 !important;">const</code> <code plain"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">CCRect&amp; rect);</code></div><div number5="" index4=""  alt2"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code comments"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: #008200 !important;">//CCSpriteFrame表示精灵的某一帧，大多数情况下精灵本身的图片有多帧。它内部封装了CCTexture2D和CCRect，可以从一个大图片取出一部分作为一帧。</code></div><div number6="" index5=""  alt1"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code keyword=""  bold"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: #006699 !important;">static</code> <code plain"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame);</code></div><div number7="" index6=""  alt2"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code comments"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: #008200 !important;">//pszSpriteFrameName表示帧的名字，根据帧名从内存中取出CCSpriteFrame</code></div><div number8="" index7=""  alt1"="" style="padding-right: 1em !important; padding-left: 1em !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important;"><code keyword=""  bold"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: #006699 !important;">static</code> <code plain"="" -moz-br-"="" style="border-top-left-radius: 0px !important; border-top-right-radius: 0px !important;"></code></div></div></td></tr></tbody></table></div></div><img src ="http://www.blogjava.net/demibug/aggbug/396276.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-03-11 11:04 <a href="http://www.blogjava.net/demibug/archive/2013/03/11/396276.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于C++类成员函数的重载、覆盖、隐藏与virtual关键字</title><link>http://www.blogjava.net/demibug/archive/2013/03/10/396260.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Sun, 10 Mar 2013 12:06:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/03/10/396260.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/396260.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/03/10/396260.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/396260.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/396260.html</trackback:ping><description><![CDATA[<span style="font-family: Arial; background-color: #ffffff;">最近看&lt;&lt;高质量C++&gt;&gt;时读到的关于成员函数的重载/覆盖/隐藏,把我的一点理解写出来,希望大家批评与指正.</span><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;">1.&nbsp;<span style="font-family: 宋体;">重载、覆盖与隐藏</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">1)<span style="font-family: 宋体;">．重载：成员函数具有以下的特征时发生&#8220;重载&#8221;</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">A<span style="font-family: 宋体;">．相同的范围（同一个类中）</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">B<span style="font-family: 宋体;">．函数的名字相同</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">C<span style="font-family: 宋体;">．参数类型不同（不能进行隐式类型转换）</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">D<span style="font-family: 宋体;">．</span>Virtual<span style="font-family: 宋体;">关键字可有可无</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">2)<span style="font-family: 宋体;">．覆盖（也叫&#8220;继承&#8221;）：指派生类函数覆盖基类函数，特征是：</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">A<span style="font-family: 宋体;">．不同的范围（分别位于基类与派生类中）</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">B<span style="font-family: 宋体;">．函数名字相同</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">C<span style="font-family: 宋体;">．参数相同</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">D<span style="font-family: 宋体;">．基类函数必须有</span>virtual<span style="font-family: 宋体;">关键字</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">3)<span style="font-family: 宋体;">．隐藏：是指派生类的函数屏蔽了与其同名的基类函数，规则如下：</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">A<span style="font-family: 宋体;">．如果派生类的函数与基类的函数同名，但是参数不同，此时不论有无</span>virtual<span style="font-family: 宋体;">关键字，基类的函数都将被隐藏，注意别与重载混淆）</span></p><p style="margin: 0cm 0cm 0.0001pt 21pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">B<span style="font-family: 宋体;">．如果派生类的函数与基类的函数同名，并且参数也相同，但是基类函数没有</span>virtual<span style="font-family: 宋体;">关键字，此时基类的函数被隐藏（注意别与覆盖混淆）</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;">&nbsp;</p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;">2<span style="font-family: 宋体;">．看下面这个例子代码：</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;"></p><div style="font-family: Arial; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 995.671875px;"><span style="color: #008080;">&nbsp;1</span>&nbsp;#include&nbsp;&lt;iostream&gt;<br /><span style="color: #008080;">&nbsp;2</span>&nbsp;<span style="color: #0000ff;">using</span>&nbsp;std::cout;<br /><span style="color: #008080;">&nbsp;3</span>&nbsp;<span style="color: #0000ff;">using</span>&nbsp;std::endl;<br /><span style="color: #008080;">&nbsp;4</span>&nbsp;<br /><span style="color: #008080;">&nbsp;5</span>&nbsp;<span style="color: #0000ff;">class</span>&nbsp;Base<br /><span style="color: #008080;">&nbsp;6</span>&nbsp;{<br /><span style="color: #008080;">&nbsp;7</span>&nbsp;<span style="color: #0000ff;">public</span>:<br /><span style="color: #008080;">&nbsp;8</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">virtual</span>&nbsp;<span style="color: #0000ff;">void</span>&nbsp;f(<span style="color: #0000ff;">float</span>&nbsp;x){&nbsp;cout&nbsp;&lt;&lt;&nbsp;"Base::f(float)&nbsp;"&nbsp;&lt;&lt;&nbsp;x&nbsp;&lt;&lt;&nbsp;endl;}<br /><span style="color: #008080;">&nbsp;9</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">void</span>&nbsp;g(<span style="color: #0000ff;">float</span>&nbsp;x){&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"Base::g(float)&nbsp;"&nbsp;&lt;&lt;&nbsp;x&nbsp;&lt;&lt;&nbsp;std::endl;}<br /><span style="color: #008080;">10</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">void</span>&nbsp;h(<span style="color: #0000ff;">float</span>&nbsp;x){&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"Base::h(float)&nbsp;"&nbsp;&lt;&lt;&nbsp;x&nbsp;&lt;&lt;std::endl;}<br /><span style="color: #008080;">11</span>&nbsp;};<br /><span style="color: #008080;">12</span>&nbsp;<br /><span style="color: #008080;">13</span>&nbsp;<span style="color: #0000ff;">class</span>&nbsp;Derived&nbsp;:&nbsp;<span style="color: #0000ff;">public</span>&nbsp;Base<br /><span style="color: #008080;">14</span>&nbsp;{<br /><span style="color: #008080;">15</span>&nbsp;<span style="color: #0000ff;">public</span>:<br /><span style="color: #008080;">16</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">virtual</span>&nbsp;<span style="color: #0000ff;">void</span>&nbsp;f(<span style="color: #0000ff;">float</span>&nbsp;x){&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"Derived::f(float)&nbsp;"&nbsp;&lt;&lt;&nbsp;x&nbsp;&lt;&lt;&nbsp;std::endl;}<br /><span style="color: #008080;">17</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">void</span>&nbsp;g(<span style="color: #0000ff;">int</span>&nbsp;x){&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"Derived::g(int)&nbsp;"&nbsp;&lt;&lt;&nbsp;x&nbsp;&lt;&lt;&nbsp;std::endl;}<br /><span style="color: #008080;">18</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">void</span>&nbsp;h(<span style="color: #0000ff;">float</span>&nbsp;x){&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"Derived::h(float)&nbsp;"&nbsp;&lt;&lt;&nbsp;x&nbsp;&lt;&lt;&nbsp;std::endl;}<br /><span style="color: #008080;">19</span>&nbsp;};<br /><span style="color: #008080;">20</span>&nbsp;<br /><span style="color: #008080;">21</span>&nbsp;<span style="color: #0000ff;">void</span>&nbsp;main(<span style="color: #0000ff;">void</span>)<br /><span style="color: #008080;">22</span>&nbsp;{<br /><span style="color: #008080;">23</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Derived&nbsp;d;<br /><span style="color: #008080;">24</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Base&nbsp;*pb&nbsp;=&nbsp;&amp;d;<br /><span style="color: #008080;">25</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Derived&nbsp;*pd&nbsp;=&nbsp;&amp;d;<br /><span style="color: #008080;">26</span>&nbsp;<br /><span style="color: #008080;">27</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pb-&gt;f(3.14f);<span style="color: #008000;">//</span><span style="color: #008000;">Derived::f(float)&nbsp;3.14</span><span style="color: #008000;"><br /></span><span style="color: #008080;">28</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pd-&gt;f(3.14f);<span style="color: #008000;">//</span><span style="color: #008000;">Derived::f(float)&nbsp;3.14</span><span style="color: #008000;"><br /></span><span style="color: #008080;">29</span>&nbsp;<br /><span style="color: #008080;">30</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pb-&gt;g(3.14f);<span style="color: #008000;">//</span><span style="color: #008000;">Base::g(float)&nbsp;3.14</span><span style="color: #008000;"><br /></span><span style="color: #008080;">31</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pd-&gt;g(3.14f);<span style="color: #008000;">//</span><span style="color: #008000;">Derived::g(int)&nbsp;3</span><span style="color: #008000;"><br /></span><span style="color: #008080;">32</span>&nbsp;<br /><span style="color: #008080;">33</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pb-&gt;h(3.14f);<span style="color: #008000;">//</span><span style="color: #008000;">Base:h(float)&nbsp;3.14</span><span style="color: #008000;"><br /></span><span style="color: #008080;">34</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pd-&gt;h(3.14f);<span style="color: #008000;">//</span><span style="color: #008000;">Derived::h(float)&nbsp;3.14</span><span style="color: #008000;"><br /></span><span style="color: #008080;">35</span>&nbsp;}<span style="color: #008080;"><br /></span></div><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;">&nbsp;</p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;">3.&nbsp;<span style="font-family: 宋体;">解释</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 宋体;">在</span>27<span style="font-family: 宋体;">与</span>28<span style="font-family: 宋体;">行，派生类的</span>Derived::f(float x)<span style="font-family: 宋体;">通过</span>virtual<span style="font-family: 宋体;">关键字继承（覆盖）了基类的</span>Base::f(float x)<span style="font-family: 宋体;">方法，所以这里无论采有基类指针还是派生类指针，最后调用的其实都是</span>Derived::f(float x)<span style="font-family: 宋体;">方法。这正是一般情况我们所期望的。</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 宋体;">在</span>30<span style="font-family: 宋体;">行，由于基类的</span>Base::g()<span style="font-family: 宋体;">没有用</span>virtual<span style="font-family: 宋体;">关键字声明，所以这里它不会被派生类的</span>Derived::g()<span style="font-family: 宋体;">方法覆盖。所以通过基类指针访问时只能访问到</span>Base::g(float x)<span style="font-family: 宋体;">，而在</span>31<span style="font-family: 宋体;">行通过派生类指针时可以访问的方法有</span>Base::g(float x)<span style="font-family: 宋体;">和</span>Derived::g(int x)<span style="font-family: 宋体;">，这两个方法虽然方法名相同而且参数不同（似乎）符合重载的标准，但是它们却分属于不同的&#8220;域&#8221;因此重载不会发生，这时</span>Derived::g(int x)<span style="font-family: 宋体;">就只能把</span>Base::g(float x)<span style="font-family: 宋体;">&#8220;隐藏&#8221;掉。</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;"><span style="font-family: 宋体;">同上，在第</span>33<span style="font-family: 宋体;">行通过基类指针能访问的方法只有</span>Base::h(float x)<span style="font-family: 宋体;">，由于该方法没有被</span>virtual<span style="font-family: 宋体;">关键字声明，所以不会被派生类方法</span>Derived::h(float x)<span style="font-family: 宋体;">&#8220;替换&#8221;，因此调用的是</span>Base::h(float x)<span style="font-family: 宋体;">。而在第</span>34<span style="font-family: 宋体;">行通过派生类指针可以访问的方法同时有</span>Base::h(float x)<span style="font-family: 宋体;">与</span>Derived::h(float x)<span style="font-family: 宋体;">，这似乎又冲突，而这时</span>C++<span style="font-family: 宋体;">的&#8220;隐藏&#8221;规则发生作用，所以派生类方法</span>Derived::h(float x)<span style="font-family: 宋体;">把基类方法</span>Base::h(float x)<span style="font-family: 宋体;">&#8220;隐藏&#8221;，于是</span>Derived::h(float x)<span style="font-family: 宋体;">被调用。</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff; text-indent: 21pt;">&nbsp;</p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;">4<span style="font-family: 宋体;">．总结</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C++<span style="font-family: 宋体;">的&#8220;重载&#8221;、&#8220;继承&#8221;与&#8220;隐藏&#8221;机制比一般想象中的要复杂，而这就突显了</span>virtual<span style="font-family: 宋体;">关键字的重要性。所以在派生类存在的前提下一，一定要把基类中可能在派生类中也实现的方法用</span>virtual<span style="font-family: 宋体;">关键字声明。除非在特殊情况下，比如需要检查指针类型的时候。</span></p><p style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-family: 'Times New Roman'; background-color: #ffffff;"><br /></p><div style="font-family: Arial; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 995.671875px;"><span style="color: #008080;">&nbsp;1</span>&nbsp;#include&nbsp;&lt;iostream&gt;<br /><span style="color: #008080;">&nbsp;2</span>&nbsp;<span style="color: #0000ff;">using</span>&nbsp;std::cout;<br /><span style="color: #008080;">&nbsp;3</span>&nbsp;<span style="color: #0000ff;">using</span>&nbsp;std::endl;<br /><span style="color: #008080;">&nbsp;4</span>&nbsp;<br /><span style="color: #008080;">&nbsp;5</span>&nbsp;<span style="color: #0000ff;">class</span>&nbsp;Base<br /><span style="color: #008080;">&nbsp;6</span>&nbsp;{<br /><span style="color: #008080;">&nbsp;7</span>&nbsp;<span style="color: #0000ff;">public</span>:<br /><span style="color: #008080;">&nbsp;8</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">void</span>&nbsp;CheckType(<span style="color: #0000ff;">void</span>){&nbsp;cout&nbsp;&lt;&lt;&nbsp;"This's&nbsp;Base&nbsp;Ptr"&nbsp;&lt;&lt;&nbsp;endl;}<br /><span style="color: #008080;">&nbsp;9</span>&nbsp;};<br /><span style="color: #008080;">10</span>&nbsp;<br /><span style="color: #008080;">11</span>&nbsp;<span style="color: #0000ff;">class</span>&nbsp;Derived&nbsp;:&nbsp;<span style="color: #0000ff;">public</span>&nbsp;Base<br /><span style="color: #008080;">12</span>&nbsp;{<br /><span style="color: #008080;">13</span>&nbsp;<span style="color: #0000ff;">public</span>:<br /><span style="color: #008080;">14</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff;">void</span>&nbsp;CheckType(<span style="color: #0000ff;">void</span>){&nbsp;cout&nbsp;&lt;&lt;&nbsp;"This;s&nbsp;Derived&nbsp;Ptr"&nbsp;&lt;&lt;&nbsp;endl;}<br /><span style="color: #008080;">15</span>&nbsp;};<br /><span style="color: #008080;">16</span>&nbsp;<br /><span style="color: #008080;">17</span>&nbsp;<span style="color: #0000ff;">void</span>&nbsp;main(<span style="color: #0000ff;">void</span>)<br /><span style="color: #008080;">18</span>&nbsp;{<br /><span style="color: #008080;">19</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Derived&nbsp;d;<br /><span style="color: #008080;">20</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Base&nbsp;*pb&nbsp;=&nbsp;&amp;d;<br /><span style="color: #008080;">21</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Derived&nbsp;*pd&nbsp;=&nbsp;&amp;d;<br /><span style="color: #008080;">22</span>&nbsp;<br /><span style="color: #008080;">23</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pb-&gt;CheckType();<span style="color: #008000;">//</span><span style="color: #008000;">This's&nbsp;Base&nbsp;Ptr</span><span style="color: #008000;"><br /></span><span style="color: #008080;">24</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pd-&gt;CheckType();<span style="color: #008000;">//</span><span style="color: #008000;">This's&nbsp;Derived&nbsp;Ptr</span><span style="color: #008000;"><br /></span><span style="color: #008080;">25</span>&nbsp;}<br /><span style="color: #008080;">26</span>&nbsp;</div><img src ="http://www.blogjava.net/demibug/aggbug/396260.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-03-10 20:06 <a href="http://www.blogjava.net/demibug/archive/2013/03/10/396260.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cocos2dx使用 TexturePacker导出的.plist</title><link>http://www.blogjava.net/demibug/archive/2013/03/10/396256.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Sun, 10 Mar 2013 08:38:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/03/10/396256.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/396256.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/03/10/396256.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/396256.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/396256.html</trackback:ping><description><![CDATA[<ol start="1" style="padding: 0px; border: none; list-style-position: initial; list-style-image: initial; color: #5c5c5c; font-family: Consolas, 'Courier New', Courier, mono, serif; line-height: 26px; margin: 0px 0px 1px 45px !important;"><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black;"><span style="margin: 0px; padding: 0px; border: none;">CCSpriteFrameCache*&nbsp;cache&nbsp;=&nbsp;CCSpriteFrameCache::sharedSpriteFrameCache();&nbsp;&nbsp;</span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; background-color: #f8f8f8; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">&nbsp;&nbsp;&nbsp;&nbsp;cache-&gt;addSpriteFramesWithFile(<span style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"test.plist"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">,&nbsp;</span><span style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"test.png"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">);&nbsp;&nbsp;</span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; background-color: #f8f8f8; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="margin: 0px; padding: 0px; border: none; color: #008200; background-color: inherit;">/*&nbsp;创建Sprite&nbsp;*/</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">&nbsp;&nbsp;</span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;CCSprite*&nbsp;s1&nbsp;=&nbsp;CCSprite::createWithSpriteFrame(cache-&gt;spriteFrameByName(<span style="margin: 0px; padding: 0px; border: none; color: blue;">"g_good.png"</span><span style="margin: 0px; padding: 0px; border: none;">));&nbsp;&nbsp;</span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; background-color: #f8f8f8; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;s1-&gt;setPosition(ccp(100,&nbsp;100));&nbsp;&nbsp;</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; background-color: #f8f8f8; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">&nbsp;&nbsp;&nbsp;&nbsp;addChild(s1);&nbsp;&nbsp;</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; background-color: #f8f8f8; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">&nbsp;&nbsp;&nbsp;&nbsp;CCSprite*&nbsp;s2&nbsp;=&nbsp;CCSprite::createWithSpriteFrame(cache-&gt;spriteFrameByName(<span style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"musicBtn.png"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">));&nbsp;&nbsp;</span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; background-color: #f8f8f8; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">&nbsp;&nbsp;&nbsp;&nbsp;s2-&gt;setPosition(ccp(300,&nbsp;300));&nbsp;&nbsp;</span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: #6ce26c; list-style: decimal-leading-zero outside; color: inherit; line-height: 18px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;addChild(s2);&nbsp;</span></li></ol><img src ="http://www.blogjava.net/demibug/aggbug/396256.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-03-10 16:38 <a href="http://www.blogjava.net/demibug/archive/2013/03/10/396256.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>cocos2d中CCCallFunc、CCCallFuncN和CCCallFuncND的区别</title><link>http://www.blogjava.net/demibug/archive/2013/02/26/395756.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Tue, 26 Feb 2013 07:36:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/02/26/395756.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/395756.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/02/26/395756.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/395756.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/395756.html</trackback:ping><description><![CDATA[<p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">cocos2d中有3种回调方式：CCCallFunc、CCCallFuncN和CCCallFuncND</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">其中，他们有什么区别呢？</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">这里我稍微总结下，不对的欢迎讨论和拍砖！</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">看源代码的excute方法，我总结下面3点：</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">1.&nbsp;CCCallFunc</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;"></p><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: #ffffff; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; line-height: 25.1875px;"><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold;">C代码&nbsp;<embed wmode="transparent" src="http://wsqwsq000.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=-(void)%20execute%0A%7B%0A%09%5BtargetCallback%20performSelector%3Aselector%5D%3B%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="" title="收藏这段代码" style="color: #108ac6;"><img src="http://wsqwsq000.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border: 1px solid #d1d7dc; color: #2b91af;"><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">-(<span style="color: #7f0055;">void</span>)&nbsp;execute&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">{&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;[targetCallback&nbsp;performSelector:selector];&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">}&nbsp;&nbsp;</li></ol></div><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">CCCallFunc是执行对应的回调方法，其中回调方法不可带参数。</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">2.&nbsp;CCCallFuncN</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;"></p><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: #ffffff; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; line-height: 25.1875px;"><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold;">C代码&nbsp;<embed wmode="transparent" src="http://wsqwsq000.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=-(void)%20execute%0A%7B%0A%09%5BtargetCallback%20performSelector%3Aselector%20withObject%3Atarget%5D%3B%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="" title="收藏这段代码" style="color: #108ac6;"><img src="http://wsqwsq000.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border: 1px solid #d1d7dc; color: #2b91af;"><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">-(<span style="color: #7f0055;">void</span>)&nbsp;execute&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">{&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;[targetCallback&nbsp;performSelector:selector&nbsp;withObject:target];&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">}&nbsp;&nbsp;</li></ol></div><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;CCCallFuncN多带一个参数，而参数本身是动作Aciton本身。就像UIButton那样，我们可以@selector(btnUpInside:)，带的参数就是UIButton本身。</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">3.&nbsp;CCCallFuncND</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;"></p><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: #ffffff; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; line-height: 25.1875px;"><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold;">C代码&nbsp;<embed wmode="transparent" src="http://wsqwsq000.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=-(void)%20execute%0A%7B%0A%09%5Binvocation_%20setArgument%3A%26target%20atIndex%3A2%5D%3B%0A%09%5Binvocation_%20setArgument%3A%26data%20atIndex%3A3%5D%3B%0A%09%5Binvocation_%20invoke%5D%3B%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="" title="收藏这段代码" style="color: #108ac6;"><img src="http://wsqwsq000.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px;" /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border: 1px solid #d1d7dc; color: #2b91af;"><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">-(<span style="color: #7f0055;">void</span>)&nbsp;execute&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">{&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;[invocation_&nbsp;setArgument:&amp;target&nbsp;atIndex:2];&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;[invocation_&nbsp;setArgument:&amp;data&nbsp;atIndex:3];&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;[invocation_&nbsp;invoke];&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px;">}&nbsp;&nbsp;</li></ol></div><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">CCCallFuncND带2个参数，一个是动作Action本身，一个是你自己定义的回调函数的参数。</span><img src ="http://www.blogjava.net/demibug/aggbug/395756.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-02-26 15:36 <a href="http://www.blogjava.net/demibug/archive/2013/02/26/395756.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cocos2dx 中文支持</title><link>http://www.blogjava.net/demibug/archive/2013/01/15/394268.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Tue, 15 Jan 2013 11:26:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/01/15/394268.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/394268.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/01/15/394268.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/394268.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/394268.html</trackback:ping><description><![CDATA[<div><p style="color: #333333; font-family: Arial; line-height: 26px;">将需要的字符串保存于 strings.xml文件中：</p><p style="color: #333333; font-family: Arial; line-height: 26px;"></p><div bg_html"="" style="width: 687.046875px; color: #333333; line-height: 26px;"><div><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">&lt;?</span><span style="color: #FF00FF; ">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"</span><span style="color: #0000FF; ">?&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br /></span><span style="color: #0000FF; ">&lt;!</span><span style="color: #FF00FF; ">DOCTYPE&nbsp;plist&nbsp;PUBLIC&nbsp;"-<br />//Apple//DTD&nbsp;PLIST&nbsp;1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br /></span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">plist&nbsp;</span><span style="color: #FF0000; ">version</span><span style="color: #0000FF; ">="1.0"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br /></span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">dict</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">key</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">title</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">key</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">string</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">是男人就坚持20秒</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">string</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">key</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">new_game</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">key</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">string</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">新游戏</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">string</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">key</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">setting_game</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">key</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">string</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">设置</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">string</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">key</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">quit_game</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">key</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">string</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">退出</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">string</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br /></span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">dict</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br /></span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">plist</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br /></span></div></div></div><span style="color: #333333; font-family: Arial; line-height: 26px;">然后在代码中读取：</span><p style="color: #333333; font-family: Arial; line-height: 26px;"></p><p style="color: #333333; font-family: Arial; line-height: 26px;"><span style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 25px;">CCDictionary *strings = CCDictionary::createWithContentsOfFile("fonts/strings.xml");</span></p><p style="color: #333333; font-family: Arial; line-height: 26px;"><span style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 25px;">const char *titleStr = (CCString*)strings-&gt;objectForKey("title")-&gt;m_sString.c_str();</span></p><p style="color: #333333; font-family: Arial; line-height: 26px;"><span style="font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 25px;">......</span></p></div><img src ="http://www.blogjava.net/demibug/aggbug/394268.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-01-15 19:26 <a href="http://www.blogjava.net/demibug/archive/2013/01/15/394268.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Activity.startActivityForResult</title><link>http://www.blogjava.net/demibug/archive/2013/01/01/393686.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Tue, 01 Jan 2013 15:14:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/01/01/393686.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/393686.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/01/01/393686.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/393686.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/393686.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 打开新的Activity，传递参数给它第二种：打开新的Activity，并传递若干个参数给它：01020304050607080910111213public class MainActivity extends Activity {&nbsp;&nbsp;@Override protected void onCreate(Bundle savedInstanceState) {&nbsp;&nb...&nbsp;&nbsp;<a href='http://www.blogjava.net/demibug/archive/2013/01/01/393686.html'>阅读全文</a><img src ="http://www.blogjava.net/demibug/aggbug/393686.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-01-01 23:14 <a href="http://www.blogjava.net/demibug/archive/2013/01/01/393686.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>遍历hash map</title><link>http://www.blogjava.net/demibug/archive/2013/01/01/393669.html</link><dc:creator>Hiji</dc:creator><author>Hiji</author><pubDate>Mon, 31 Dec 2012 21:01:00 GMT</pubDate><guid>http://www.blogjava.net/demibug/archive/2013/01/01/393669.html</guid><wfw:comment>http://www.blogjava.net/demibug/comments/393669.html</wfw:comment><comments>http://www.blogjava.net/demibug/archive/2013/01/01/393669.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/demibug/comments/commentRss/393669.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/demibug/services/trackbacks/393669.html</trackback:ping><description><![CDATA[<div><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;遍历hashmap&nbsp;Itterator&lt;&nbsp;Map.Entry&lt;K,V&gt;&nbsp;&gt;</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Iterator&lt;Map.Entry&lt;String,&nbsp;String&gt;&gt;&nbsp;iter&nbsp;=&nbsp;wallLayer.properties.entrySet().iterator();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">while</span>&nbsp;(iter.hasNext())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Entry&lt;String,&nbsp;String&gt;&nbsp;entry&nbsp;=&nbsp;iter.next();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gdx.app.log(entry.getKey().toString(),&nbsp;entry.getValue().toString());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>&nbsp;(<span style="color: #0000FF; ">int</span>&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;wallLayer.tiles.length;&nbsp;i++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">int</span>&nbsp;arr2[]&nbsp;=&nbsp;wallLayer.tiles[i];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>&nbsp;(<span style="color: #0000FF; ">int</span>&nbsp;j&nbsp;=&nbsp;0;&nbsp;j&nbsp;&lt;&nbsp;arr2.length;&nbsp;j&nbsp;++)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gdx.app.log("tiles["&nbsp;+&nbsp;i&nbsp;+&nbsp;"]["&nbsp;+&nbsp;j&nbsp;+&nbsp;"]",&nbsp;Integer.toString(wallLayer.tiles[i][j]));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div></div> <img src ="http://www.blogjava.net/demibug/aggbug/393669.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/demibug/" target="_blank">Hiji</a> 2013-01-01 05:01 <a href="http://www.blogjava.net/demibug/archive/2013/01/01/393669.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>