- 博客(25)
- 收藏
- 关注
原创 Lua 语法学习记录一
local n = 4 function fact( n ) -- 求n的阶乘,递归 if n == 0 then return 1 else return n*fact(n-1) end end print(fact(n)) -- 24 print(type(
2014-11-11 16:16:08
629
原创 C++ 之 函数指针
void say(int x, int y){ cout << x << y << endl;}int main(){ void (*func)(int,int); //func = say; //都可以 func = &say; (*func)(1,1); func(1,1); system("pause"); return 0;}
2014-10-11 22:39:26
523
原创 C++ 之 部分容器的使用
#include #include #include #include using namespace std;int main(){ /********* list ********/ list lis; lis.push_back("hello"); lis.push_back("world"); for (auto it = lis.begin(); it!=l
2014-08-11 14:04:49
495
原创 C++ 之 伪函数
#include using namespace std;class Say{public: void operator()(){ //重载()符号 printf("hello ()"); }};int main(){ Say s; s(); //像函数一样调用,其实是一个类 system("pause"); return 0;}
2014-08-11 10:05:33
748
原创 C++ 之 运算符重载
#include using namespace std;class point{private: int a,b;public: point(int a, int b){ //构造方法 this->a = a; this->b = b; } int getA(){ return this->a; } int getB(){ return this->b
2014-08-11 10:01:05
483
原创 C++ 之 虚函数、纯虚函数
#include #include class people{public: void say(){ printf("hello people.\n"); }};class man:public people{public: void say(){ printf("hello man.\n"); }};int main(){ people * p =
2014-08-11 09:33:55
542
原创 C++ 之 构造函数、析构函数
#include class Object {public: Object(){ //定义构造函数 printf("Create Object. \n"); }; ~Object(){ //定义析构函数 printf("Delete Object. \n"); }};int main(){ Object * o = new Object(); system("
2014-08-04 20:13:32
599
原创 C++ 之 对象的实现
people.h#include class People{public: void sayHello(){} People(){}};people.cpp
2014-08-04 19:33:36
519
原创 Cocos2dx 3.1.1 之 计时器
HelloWorld.h文件部分内容:class HelloWorld : public cocos2d::Layer{private: LabelTTF * label; //定时去移动一个Labelpublic: static cocos2d::Scene* createScene(); virtual bool init(); CREATE_FUNC(
2014-08-04 09:59:13
801
原创 Cocos2dx 3.1.1 之 加速传感器、监听物理按键
//打开加速传感器(默认是关闭的) Device::setAccelerometerEnabled(true); //监听函数 Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(EventListenerAcceleration:: create([](Accele
2014-08-01 09:50:13
900
原创 Cocos2dx 3.1.1 之 多点触碰监听
//多点触碰监听器 auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = [](std::vector ts, Event *e){ log(" --- onTouchesBegan --- "); }; listener->onTouchesMoved = [](std:
2014-08-01 09:27:57
682
原创 Cocos2dx 3.1.1 之 监听触屏事件
//监听器 auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [](Touch * t, Event * e){ log(" --- onTouchBegan --- "); return true; //return false; //此处返回false,则onTouc
2014-07-31 19:56:59
960
原创 Cocos2dx 3.1.1 之 plist制作动画
////动画,可以用flash来制作plist,导出时候有2.x和3.x的区别 auto cache = SpriteFrameCache::getInstance(); cache->addSpriteFramesWithFile("anim.plist", "anim.png"); //用容器来存放每一帧 Vector vec; char name[15]; memset(nam
2014-07-31 19:20:38
1144
原创 Cocos2dx 3.1.1 之 监听器、特效切换场景、动作、检测碰撞、回调函数
auto * sprite = Sprite::create("HelloWorld.png"); sprite->setPosition(200, 200); this->addChild(sprite); LabelTTF * ttf = LabelTTF::create("to next Scene.", "Courier", 20); this->addChild(ttf);
2014-07-31 19:16:08
923
原创 Cocos2d-x 3.1.1 之 MessageBox、LabelTTF、菜单、
if ( !Layer::init() ) { return false; } Size size = Director::getInstance()->getVisibleSize(); //MessageBox("消息内容", "消息标题"); LabelTTF * ttf = LabelTTF::create(); ttf->setSt
2014-07-31 19:11:58
1137
原创 按钮
/* 扣血飘字特效 */ FlowWord* flowWord = FlowWord::create(); this->addChild(flowWord); flowWord->showWord("-15", getSprite()->getPosition());
2014-07-31 19:03:36
586
原创 使用plist创建动画
代码说话: CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); frameCache->addSpriteFramesWithFile("run.plist", "run.png"); CCSpriteFrame* frame = NULL; CCArray* frameList
2014-07-31 18:47:12
783
原创 创建精灵、执行动作
创建精灵: //图片创建精灵,植物 CCSprite * plant = CCSprite::create("Peashooter1.tiff"); plant->setPosition(ccp(300, 300)); //帧创建精灵步骤1 CCSpriteFrame * frame = CCSpriteFrame::create("Peashooter1.tiff", CCRe
2014-07-31 17:25:08
629
原创 cocos2d-x 3.1.1 在vs2012上新建工程
本文章参考了:IT_xiao小巫 的 http://blog.youkuaiyun.com/wwj_748/article/details/24812277
2014-07-13 17:58:39
1305
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人