The Plane.
来源:互联网 发布:fifaol数据库 编辑:程序博客网 时间:2024/06/09 21:44
The Plane_mainMenu
2014-04-16
-----------------------------------------------------------------------------------------------------
三个文字Lable
创建成Menu后,第一个Label字体明显比第二个字体大,将CCMenuItemFont的setFont全去掉后,变成如图模样。
感觉很奇怪,原因思考中。
_gameStart = CCMenuItemFont::create("Start", this, menu_selector(GameLayer::menuStartCallBack));_gameStart->setColor(ccc3(255, 255, 255));_gameEnd = CCMenuItemFont::create("Exit", this, menu_selector(GameLayer::menuEndCallBack));_gameEnd->setColor(ccc3(255, 255, 255));_gameMainMenu = CCMenu::create(_gameStart, _gameEnd, NULL);_gameMainMenu->setPosition(ccp(_screenSize.width*0.5, _screenSize.height*0.5));_gameMainMenu->alignItemsVerticallyWithPadding(50);_gameMainMenu->setContentSize(CCSizeMake(100, 100));this->addChild(_gameMainMenu,0);
2014-04-17
-----------------------------------------------------------------------------------------------------
今天添加了按钮scene切换,点击Start跳转到游戏黑屏,Exit退出游戏。
void GameIn::menuBackMenu(CCObject* pSender){CCDirector::sharedDirector()->replaceScene(GameLayer::scene());}
2014-04-18
-----------------------------------------------------------------------------------------------------
团建。
2014-04-19
-----------------------------------------------------------------------------------------------------
团建。
2014-04-20
-----------------------------------------------------------------------------------------------------
今天准备好了画线,点,形。_gameObjectBullet = GameObject::create();_gameObjectBullet->setPivot(ccp(100, 100));_gameObjectBullet->setTip(ccp(200, 200));_gameObjectBullet->setShapesType(OBJ_LINE);_gameObjectBullet->draw();this->addChild(_gameObjectBullet);_gameObjectPlane = GameObject::create();_gameObjectPlane->setTip(ccp(150, 150));_gameObjectPlane->setShapesType(OBJ_POINT);_gameObjectPlane->draw();this->addChild(_gameObjectPlane);_gameObjectEnemy = GameObject::create();_gameObjectEnemy->setTip(ccp(300, 300));_gameObjectEnemy->setPivot(ccp(260, 260));_gameObjectEnemy->setShapesType(OBJ_RECT);_gameObjectEnemy->draw();this->addChild(_gameObjectEnemy);
2014-04-21
-----------------------------------------------------------------------------------------------------
今天添加了触摸事件,现在可以搬运着方框到处跑拉,当然,是无限制的。明天完善一下。
遇到问题:error C2061: 语法错误: 标识符“CCSet”
解决方法:在相应文件中添加引用宏“USING_NS_CC;”
实现以下三个方法:
virtual voidccTouchesBegan(CCSet* pTouches, CCEvent* event); virtual voidccTouchesMoved(CCSet* pTouches, CCEvent* event); virtual voidccTouchesEnded(CCSet* pTouches, CCEvent* event);
在init方法中设置可触摸为true
this->setTouchEnabled(true);
拖动的动作主要是在moved中实现的。
2014-04-22
-----------------------------------------------------------------------------------------------------
今天头脑风暴,屏幕移动还没有实现完成,明天需要继续。最近几天头好乱,思绪是一点都没有拉。
以飞机为中心,四个方向
//up (down,left,right)
//down (up,left,right)
//left(up,down,right)
//right(up,down,left)
后来一想好像不对,触摸屏幕中的任意一点,不用来区分上下左右,还是直接计算触摸点和拖动点的距离差比较靠谱些。
2014-04-23
-----------------------------------------------------------------------------------------------------
今天终于明白之前的错误在哪里了,今天我重新写了GameObject类,继续了CCNode,和CCTargetedTouchDelegate。
virtualvoid onEnter();
virtualvoid onExit();
boolcontainsTouchLocation(CCTouch* touch);
virtualbool ccTouchBegan(CCTouch* touch, CCEvent* event);
virtualvoid ccTouchMoved(CCTouch* touch, CCEvent* event);
virtualvoid ccTouchEnded(CCTouch* touch, CCEvent* event);
virtualvoid touchDelegateRetain();
virtualvoid touchDelegateRelease();
实现方法如上,在OnEnter()中添加触摸响应。
偏移计算方法为
bool GameObject::ccTouchBegan(CCTouch*touch, CCEvent* event){
if(!containsTouchLocation(touch)){
returnfalse;
}
else{
iscontrol= true;
CCPointtap = touch->getLocationInView();
tap= CCDirector::sharedDirector()->convertToGL(tap);
offset.x= tap.x - this->getPosition().x;
offset.y= tap.y - this->getPosition().y;
}
returntrue;
}
void GameObject::ccTouchMoved(CCTouch*touch, CCEvent* event){
if(iscontrol){
CCPointtap = touch->getLocationInView();
tap= CCDirector::sharedDirector()->convertToGL(tap);
floatx = tap.x - offset.x;
floaty = tap.y - offset.y;
//setPosition(ccp(tap.x,getPosition().y));
this->setPosition(x,y);
}
}
这样就可以实现随拖动坐标走动了,但现在有一个不好的地方,必须要触摸到Plane才会移动,可以考虑优化为触摸屏幕上任意一点,都随着移动,因为有些时候,你的手可能会挡到飞机拉,有那么复杂吗?哈哈,很简单拉,只需要把 if(!containsTouchLocation(touch)){
returnfalse;
}
去掉就OK拉,现在不必是必须触摸飞机本身喽,屏幕里的任意点都会生效。
隐形坑:
这里要注意的是getLocation()和getLocationInView(),前者在这种移动方法中,可能会造成Y轴反方向,所以需要使用在视图内的Location.
/** returns the current touch location in screen coordinates */
CCPoint getLocationInView() const;
/** returns the current touch location in OpenGL coordinates */
CCPoint getLocation() const;
看到了吧,getLocation是返回在OpenGl中的坐标,面OpenGl的坐标系好像正好和实际相反。
2014-04-24
-----------------------------------------------------------------------------------------------------
今天预想的是添加子弹,但遇到了一些问题,最后决定先添加一个激光枪吧,嘿嘿,因为它不涉及什么先后出现顺序问题,就一直在那就行拉。明天在继续想一下怎么实现圈圈子弹效果。
这些还都没有设置碰撞体,等先把子弹效果实现在来添加一下。
2014-05-03
-----------------------------------------------------------------------------------------------------
终于有时间来继续这个了,3.0了,好快。
《1》draw不能再被重写了,那么我们只能来用另外一个带好多参数的了,但调用方法和之前一样。
《2》touch需要注册下listen了,要不不会在触发。
Node::onEnter(); // Register Touch Event auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); listener->onTouchBegan = CC_CALLBACK_2(Player::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(Player::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(Player::onTouchEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
《3》undefined reference to XXX 遇到这个一般是没有找到引用 ,寻思了半天,最后终于想起,我用的make编辑器不会自动 把你新添加的代码文件放到make列表的,自己手动加一下吧。。。。。。想了半天才想到,好2 -+-。
- The Plane.
- Essay 1 : The Plane ticket
- 1.2 Lines in the plane
- ural 1207. Median on the Plane
- Dividing The Plane 直线划分平面
- URAL 1207 Median on the Plane
- Codeforces 725B Food on the Plane
- codeforces 725B Food on the Plane
- CodeForces 725B Food on the Plane
- ural 1207. Median on the Plane(极角排序)
- Ural 1207. Median on the Plane(计算几何)
- [线性常微分方程][7]The Trace-Determinant Plane
- 计算几何 ural 1207 Median on the Plane
- Canada Cup 2016 B. Food on the Plane 找规律 .
- Codefroces 725B Food on the Plane【模拟】
- Canada Cup 2016 B. Food on the Plane
- Canada Cup 2016 B. Food on the Plane (数学)
- 平面直线切割问题 (LINES IN THE PLANE) 问题
- C#发送Post方式的Http请求
- [翻译] DFXCoreTextView
- document.execCommand()方法处理Html数据
- 使用 UIFontWDCustomLoader 载入自定义字体
- paip.提升效率--调试--日志系统日志参数含义---python
- The Plane.
- 告别恶心的CGRect设置
- 运放前端的电阻线性度的问题
- android中像素单位dp、px、pt、sp转换
- The Amazing Audio Engine
- NumPy-快速处理数据
- Glance模块研究-我们对镜像模块的需求是什么
- String和New String()的区别
- 〖IT认证经验〗系统架构师职业分析