1.字符串 与 数据结构互转

CCPoint:  CCPointFromString(); {x, y}
CCSize: CCSizeFromString(); {w, h}
CCRect: CCSizeFromString(); {x, y, w, h}

2.plist文件使用,配置文件使用

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>level1</key>
<dict>
<key>bg_far_scene</key>
<dict>
<key>path</key>
<string>images/far_scene.png</string>
<key>pos</key>
<string>{, }</string>
</dict>
<key>bg_near_scene</key>
<dict>
<key>path</key>
<string>images/near_scene.png</string>
<key>pos</key>
<string>{, }</string>
</dict>
</dict>
</dict>
</plist>
CCDictionary *data = CCDictionarycreateWithContentsOfFile("parm.plist");
data->objectForKey("gravity")

3.触摸拖动变化

ccTouchesMoved
CCPoint diff = touch->getDelta();

4.tile map

CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/iso-test-vertexz.tmx");
addChild(map, , kTagTileMap); /* 直接根据位置获取地图上的精灵 */
CCTMXLayer* layer = map->layerNamed("Trees");
m_tamara = layer->tileAt( ccp(,) );//获取的是CCSprite对象
m_tamara->retain(); /* 设置某个点的GID值,GID数字标识图块对应的图片样子 */
layer->setTileGID(1, ccp( x, y ) );
//遮挡排序
// tile height is 64x32 //斜45度
// map size: 30x30
CCPoint p = m_tamara->getPosition();
p = CC_POINT_POINTS_TO_PIXELS(p);
float newZ = -(p.y+) /;
m_tamara->setVertexZ( newZ ); // tile height is 101x81 //正交
// map size: 12x12
CCPoint p = m_tamara->getPosition();
p = CC_POINT_POINTS_TO_PIXELS(p);
m_tamara->setVertexZ( -( (p.y+) /) ); //缩小,2秒缩小一半
CCArray* pChildrenArray = map->getChildren();
CCSpriteBatchNode* child = NULL;
CCObject* pObject = NULL;
CCARRAY_FOREACH(pChildrenArray, pObject)
{
child = (CCSpriteBatchNode*)pObject; if(!child)
break; child->getTexture()->setAntiAliasTexParameters();
}
map->runAction( CCScaleBy::create(, 0.5f) );

5.给Scene层抹上底色

CCLayerColor* color = CCLayerColor::create( ccc4(,,,) );
addChild(color, -);

6.动作移动地图

// move map to the center of the screen
CCSize ms = map->getMapSize();
CCSize ts = map->getTileSize();
map->runAction( CCMoveTo::create(1.0f, ccp( -ms.width * ts.width/, -ms.height * ts.height/ )) );

7.动作

CCActionInterval* move = CCMoveBy::create(0.5f, ccp(,));
CCActionInterval* rotate = CCRotateBy::create(, );
CCActionInterval* scale = CCScaleBy::create(, );
CCActionInterval* opacity = CCFadeOut::create();
CCActionInterval* fadein = CCFadeIn::create();
CCActionInterval* scaleback = CCScaleTo::create(, );
CCActionInstant* finish = CCCallFuncN::create(this, callfuncN_selector(TMXReadWriteTest::removeSprite));
CCSequence* seq0 = CCSequence::create(move, rotate, scale, opacity, fadein, scaleback, finish, NULL); void TMXReadWriteTest::removeSprite(CCNode* sender)
{
////----CCLOG("removing tile: %x", sender);
CCNode* p = ((CCNode*)sender)->getParent(); if (p)
{
p->removeChild((CCNode*)sender, true);
} //////----CCLOG("atlas quantity: %d", p->textureAtlas()->totalQuads());
}

8.对于对象节点

CCTMXTiledMap* map = (CCTMXTiledMap*) getChildByTag(kTagTileMap);
CCTMXObjectGroup* group = map->objectGroupNamed("Object Group 1"); CCArray* objects = group->getObjects();
CCDictionary* dict = NULL;
CCObject* pObj = NULL;
CCARRAY_FOREACH(objects, pObj)
{
dict = (CCDictionary*)pObj; if(!dict)
break;
const char* key = "x";
int x = ((CCString*)dict->objectForKey(key))->intValue();
key = "y";
int y = ((CCString*)dict->objectForKey(key))->intValue();
key = "width";
int width = ((CCString*)dict->objectForKey(key))->intValue();
key = "height";
int height = ((CCString*)dict->objectForKey(key))->intValue(); glLineWidth();
ccDrawLine( ccp((float)x, (float)y), ccp((float)(x+width), (float)y) );
ccDrawLine( ccp((float)(x+width), (float)y), ccp((float)(x+width), (float)(y+height)) );
ccDrawLine( ccp((float)(x+width), (float)(y+height)), ccp((float)x, (float)(y+height)) );
ccDrawLine( ccp((float)x, (float)(y+height)), ccp((float)x, (float)y) );
//获取对象的名字
key = "name";
CCString * str = ((CCString*)dict->objectForKey(key));
glLineWidth();
}

9、弹框提示

CCMessageBox("this is content","title");

10、vs中va功能---自动添加头文件查找

工具->选项->键盘

VAssistX.RefactorAddInclude设置快捷键即可

11、整个游戏速度设置^^!

float multi = 1.0f;
CCDirector::sharedDirector()->getScheduler()->setTimeScale(multi);

12、tile map 绘制的椭圆Object,x,y 表示 坐下交位置 , 中心点 centerX = x + width/2  centerY = y + height/2

cocos2d-x 小技巧的更多相关文章

  1. 前端网络、JavaScript优化以及开发小技巧

    一.网络优化 YSlow有23条规则,中文可以参考这里.这几十条规则最主要是在做消除或减少不必要的网络延迟,将需要传输的数据压缩至最少. 1)合并压缩CSS.JavaScript.图片,静态资源CDN ...

  2. Git小技巧 - 指令别名及使用Beyond Compare作为差异比较工具

    前言 本文主要写给使用命令行来操作Git的用户,用于提高Git使用的效率.至于使用命令还是GUI(Tortoise Git或VS的Git插件)就不在此讨论了,大家根据自己的的喜好选择就好.我个人是比较 ...

  3. 分享两个BPM配置小技巧

    1.小技巧 流程图修改后发布的话版本号会+1,修改次数多了之后可能会导致版本号很高,这个时候可以将流程导出,然后删除对应的流程包再导入,发布数据模型和流程图之后,版本清零 2.小技巧 有的同事入职后使 ...

  4. linux系统维护时的一些小技巧,包括系统挂载新磁盘的方法!可收藏!

    这里发布一些平时所用到的小技巧,不多,不过会持续更新.... 1.需要将history创建硬链接ln 全盘需要备份硬链接 ln /etc/xxx /home/xxx 2.root用户不可以远程 /et ...

  5. JS处理事件小技巧

    今天,就分享一下我自己总结的一些JS的小技巧: ①防止鼠标选中事件 <div class="mask" onselectstart="return false&qu ...

  6. iOS:小技巧(不断更新)

    记录下一些不常用技巧,以防忘记,复制用. 1.获取当前的View在Window的frame: UIWindow * window=[[[UIApplication sharedApplication] ...

  7. css小技巧(1)

    1.-webkit-overflow-scrolling: touch; 解决ios滑动时无缓冲问题 2.::-webkit-scrollbar 设置ios滑动时是否显示滚动条 3.::selecti ...

  8. 最强 Android Studio 使用小技巧和快捷键

    写在前面 本文翻译自 Android Studio Tips by Philippe Breault,一共收集了62个 Android Studio 使用小技巧和快捷键. 根据这些小技巧的使用场景,本 ...

  9. ios开发中的小技巧

    在这里总结一些iOS开发中的小技巧,能大大方便我们的开发,持续更新. UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIViewal ...

  10. Jquery 小技巧

    [每个程序员都会的35个jQuery的小技巧]收集的35个jQuery的小技巧/代码片段,可以帮你快速开发

随机推荐

  1. c++ 函数返回指针 及用法

    #include<string> #include<iostream> using namespace std; string fun1(int a) { string str ...

  2. eclipse中加放js文件报js语法错误解决办法

    1) eclipse设置         window->preference-> JavaScript -> Validator->Errors/Warnings->E ...

  3. ssh-add 报错 Could not open a connection to your authentication agent

    ERROR: [root@testcentos01 ~]# ssh-add Could not open a connection to your authentication agent 在shel ...

  4. 导致Asp.Net站点重启的10个原因 ,记录重启原因

    Asp.Net站点有时候会莫名其妙的重启,什么原因导致的却不得而知,经过一番折腾后,我总结了导致Asp.Net站点重启的10个原因 1. 回收应用程序池会导致站点重启,记录的原因是: HostingE ...

  5. unit3d 4.6 document open solution

    发现4.6 的 本地 文档字体解析采用 fonts.googleapis.com ,可是google 自古就与天朝不在一个鼻孔,所以你打开往往需要半天. 网上查了一下,把所有本地的*.html 文档  ...

  6. Unity3D脚本中文系列教程(十)

    http://dong2008hong.blog.163.com/blog/static/4696882720140312627682/?suggestedreading&wumii Unit ...

  7. What are Scopes?

    scope is an object that refers to the application model. It is an execution context for expressions. ...

  8. unity3d GameObject.Find 严格区分大小写的

    GameObject.Find 查找 static function Find (name : string) : GameObject Description描述 Finds a game obje ...

  9. Hadoop-eclipse-plugin插件安装

    Hadoop-eclipse-plugin插件安装 学习Hadoop有一段时间了,以前每次的做法都是先在win下用eclipse写好Mapreduce程序,然后打成jar文件,上传到linux下用ha ...

  10. @QueryParam和@PathParam比较

    来源:http://jackyrong.iteye.com/blog/1128364 1 先来看@queryparam Path("/users") public class Us ...