实现角色与墙壁的来回碰撞
来源:互联网 发布:巧克力知乎 编辑:程序博客网 时间:2024/04/28 19:50
根据上章的扩展:(这是部分打码)
void JsLayer::update(float dt){CCSize mapTiledNum = _map->getMapSize(); CCSize tiledSize = _map->getTileSize(); CCPoint point1 =this->_jsSprite->getPosition();point1.x=point1.x - this->speed;this->_jsSprite->setPosition(ccp(point1.x,point1.y));int x =this->_jsSprite->getPosition().x/ tiledSize.width; int y =this->_jsSprite->getPosition().y/ tiledSize.height; /* Cocos2d-x的默认Y坐标是由下至上的,所以要做一个相减操作 */ y = mapTiledNum.height - y; int tiledGid=_map->layerNamed("zhangai")->tileGIDAt(ccp(x,y)); int tiledGid2=_map->layerNamed("zhangai2")->tileGIDAt(ccp(x,y)); if(tiledGid!=0) { CCDictionary* propertiesDict = _map->propertiesForGID(tiledGid); /* 取得格子的zhezhao属性值 */ const CCString* prop = propertiesDict->valueForKey("zhezhao"); /* 判断zhezhao属性是否为true,是的话,不让玩家移动 */ if(prop->m_sString.compare("true") == 0) { //point1.x=point1.x +50;this->isB=true; } } if(isB==true) { CCPoint point3 =this->_jsSprite->getPosition(); point3.x =point3.x +speed*2; this->_jsSprite->setPosition(point3); } if(tiledGid2!=0) { CCDictionary* propertiesDict = _map->propertiesForGID(tiledGid2); const CCString* prop = propertiesDict->valueForKey("fanhui"); if(prop->m_sString.compare("true") == 0) { this->isB=false; } } }
0 0
- 实现角色与墙壁的来回碰撞
- Unity3d人物与墙壁碰撞问题求解
- unity3d 半透明面片或墙壁的实现
- 高炉通过拖延的墙壁与动机有声读物
- EditText文本框来回抖动的实现
- CRC32碰撞的实现
- CRC32碰撞的实现
- CRC32碰撞的实现
- 角色碰撞器。
- Cocos2d-x碰撞检查与消灭的实现
- 墙壁网线口的做法
- 制作 墙壁剥落的效果
- 华容道06--屏幕点击事件和角色间的碰撞
- 一个sql语句实现状态来回变化的方法
- JS 实现两表格里的数据来回 转移
- 用javascript实现网站来回撞动的广告图片
- 自定义控件二:实现来回摆动的小球
- 实现去哪儿来回机票选择的view
- 写给Git初学者的7个建议
- css+js简单实现126邮箱注册页面
- JS 数据类型转换
- Eclipse快捷键 注释、代码块加trycatch、system.out.println()、content assistant文本辅助等
- 不安装Oracle客户端使用PLSQL
- 实现角色与墙壁的来回碰撞
- Reporting Service textbox换行
- JAVA 7 Fork join
- 为学
- JDBC Connection Statement ResultSet DatabaseMetaData
- 常用设计模式__之【装饰设计模式】
- android底层开发
- android-关于广播机制的使用
- 扩展easyui validatebox的两个方法.移除验证和还原验证