随笔分类 - Cocos2d-x study
cocos2d-x的学习及使用
摘要:cocos2d-x之用户默认的首选项在bool HelloWorld::init()中1 // //写入用户的首选项数据,会在本地生成一个文件,即使应用程序被关闭掉,2 // //再下次重开的时候还可以访问到这个数据.存储一个字符串类型的数据,(key, value)3 // Us...
阅读全文
摘要:cocos2d-x之计时器(自动计时器和自定义计时器)HelloWorldScene.h 1 #ifndef __HELLOWORLD_SCENE_H__ 2 #define __HELLOWORLD_SCENE_H__ 3 4 #include "cocos2d.h" 5 6 class He...
阅读全文
摘要:Cocos2d-x之绘制点自定义的方法Point.h 1 // 2 // Points.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #ifndef __L01Drawing...
阅读全文
摘要:Cocos2d-x之绘制线条自定义的方法Line.h 1 // 2 // Line.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #ifndef __L01DrawingAP...
阅读全文
摘要:Cocos2d-x之绘制填充不规则多边形自定义的方法SPoly.h 1 // 2 // SPoly.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #ifndef __L01D...
阅读全文
摘要:自定义的方法Poly.h 1 // 2 // Poly.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #ifndef __L01DrawingAPI__Poly__10 #d...
阅读全文
摘要:Cocos2d-x之绘制填充圆形自定义的方法SCircle.h 1 // 2 // SCircle.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #ifndef __L01D...
阅读全文
摘要:自定义的方法Circle.h 1 // 2 // Circle.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #ifndef __L01DrawingAPI__Circle_...
阅读全文
摘要:Cocos2d-x之绘制填充矩形自定义的方法SRect.h 1 // 2 // SRect.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-30. 6 // 7 // 8 9 #ifndef __L01Drawi...
阅读全文
摘要:Cocos2d-x之绘制矩形自定义的方法Rect.h 1 // 2 // Rect.h 3 // L01DrawingAPI 4 // 5 // Created by Mac OS 10.9.3 on 15-3-29. 6 // 7 // 8 9 #ifndef __L01DrawingAP...
阅读全文
摘要:Node类中的draw()方法,重写draw方法去绘制图形 1 //创建自定义的类 2 class Shape:public Node { 3 public: 4 //重写draw方法,用于绘制图形 5 virtual void draw(){ 6 //使用DrawP...
阅读全文
摘要:1 //如何监听按键事件 2 //创建物理按键的监听事件 3 auto listener = EventListenerKeyboard::create(); 4 //按键被释放时执行的操作,EventKeyboard::KeyCode表示按键代码 5 listen...
阅读全文
摘要:cocos2d-x之加速度传感器使用真机来调试1 //加速度的默认状态是关闭的,需要手动的开启2 Device::setAccelerometerEnabled(true);3 4 //auto listener = EventListenerAcceleration::cr...
阅读全文
摘要:cocos2d-x之多点触摸事件 1 //全部所有的触摸点一起触发 2 auto listener = EventListenerTouchAllAtOnce::create(); 3 4 listener->onTouchesBegan = [](std::vector ...
阅读全文
摘要:cocos2d-x之事件传递(onTouchBegan的返回值的作用)只有当onTouchBegan的返回值是true时才执行后面的两个触摸事件 1 //onTouchBegan表示开始触摸的事件 2 listener->onTouchBegan = [](Touch *t, Event *...
阅读全文
摘要:cocos2d-x之触摸目标的判断需要在触摸事件的内部添加判断目标的代码 1 //EventListenerTouchOneByOne表示一个接一个的触发,每次触摸只能监听到一个触摸点 2 auto listener = EventListenerTouchOneByOne::create(...
阅读全文
摘要:cocos2d-x之为label添加事件监听器,单点触摸在bool HelloWorld::init() 1 //获取可见区域的大小 2 Size visibleSize = Director::getInstance()->getVisibleSize(); 3 //定义一个文本,...
阅读全文
摘要:cocos2d-x之Menu菜单选项按钮简介 //创建一个menu,第一个参数是菜单项,可变参数,相当于java中的可变参数 //MenuItemImage::create(普通状态的图片背景, 被选中的图片背景, //callback(回调,事件回调,即按钮被点击后的要执行的方法)) //[]()...
阅读全文
摘要:cocos2d-x中的内存管理机制 Object *obj = new Object(); obj->autorelease();//自动释放资源 // { // //在这段中使用obj // obj->retain();//保留对象 // obj->release();//手动释放资源 // ...
阅读全文
摘要:cocos2d-x之TableView列表HelloWorld.h#ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__#include "cocos2d.h"#include USING_NS_CC_EXT;USING_NS_CC;...
阅读全文