03 2013 档案
cocos2dx 开关 CCControlSwitch
摘要://CCLabelTTF * label1 = CCLabelTTF::create("开", "Arial-BodMT", 16);CCLabelTTF * label2 = CCLabelTTF ::create("关", "Arial-BodMT", 16);// 创建CCControlSwitch 开关// 参数1: 掩饰底图// 参数2 作为打开状态// 参数3 作为关闭状态// 参数4 作为开关触发图// 参数5 作为打开的文字// 参数6 作为关闭的文字CCControlSwitch * pSwitc
阅读全文
cocos2dx 编辑框 CCEditBox
摘要:.cpp文件bool HelloWorld::init(){ ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } CCSize size = CCDirector::sharedDirector()->getWinSize(); CCScale9Sprite * sacel9SprY=CCScale9Sprite::create("green_edit.png"); CCEditBox * bo...
阅读全文
CCMenuItem 的作用 和方法
摘要:// 菜单是游戏中必不可少的一部分的界面元素 在cocos2dx中封装了 ccmenu类// CCMenu * menu = CCMenu ::create();创建方式// 5中创建CCMenuItem // CCMenuItemFont// 参数1 显示的文字 参数2 触发的目标对象 参数3 触发的目标函数 CCMenuItemFont * itemfont = CCMenuItemFont::create("开始游戏", this,menu_selector(HelloWorld::menuFun)); itemfont->se...
阅读全文
cocos2dx输入框CCTextFieldTTF
摘要:CCSize winSize =CCDirector::sharedDirector()->getWinSize(); CCTextFieldTTF * textfield = CCTextFieldTTF::textFieldWithPlaceHolder("点击输入", "Thonburi",20); textfield->setPosition(ccp(winSize.width *0.5, winSize.height*0.5)); addChild(textfield); // 绑定接口 textfield->setDeleg
阅读全文
cocos2dx 字体设置
摘要://设置字体 CCLabelTTF * pLabel1 = CCLabelTTF ::create("hello world !", "Thonburi", 24);// CCLabelTTF * pLabel1 = CCLabelTTF ::create("hello world !", "STKaiti", 24); // pLabel1->setPosition(ccp(100, 100)); pLabel1->cocos2d::CCNode::setPosition(100, 100); add
阅读全文
cocos2dx CCSprite CCLayer 游戏基础
摘要:// CCNode 的添加 与tag// 1 添加子类函数 // CCLayer*layer =CCLayer::create();// layer->setPosition(ccp(240,200));// CCSprite*sprChild = CCSprite::create("Icon.png");// layer->addChild(sprChild);// addChild(layer);//// CCSprite* spr = CCSprite::create("Icon.png");// spr->setPositio.
阅读全文
cocos2dx CCLayer 常用的两种Layer层
摘要:// 常用的两种Layer层 CCLayer * lay = CCLayer::create();//默认的颜色是黑色 addChild(lay);// 红色 CCLayerColor * layercolor = CCLayerColor::create(ccc4(255, 0, 0, 255)); addChild(layercolor); layercolor->setPosition(ccp(250, 250)); // 蓝色 同时确定位置和颜色 CCLayerColor * layercolor1 = CCLa...
阅读全文
cocos2dx CCSprite 精灵的常用函数
摘要:// 精灵的常用函数 // add "HelloWorld" splash screen"// 创建 CCSprite* sp = CCSprite::create("Icon.png");// 位置 sp->setPosition(ccp(80,100));// 旋转 sp->setRotation(100); //0-360度// 设置放缩 sp->setScale(1.5);//0-1是缩小 大于1 就是放大了 addChild(sp); CCSprite * sp1= CCSprite::cre...
阅读全文
cocos2dx四种创建精灵的方法
摘要:// /====创建精灵的四种方法 CCSprite * spr1 = CCSprite::create("Icon.png"); spr1->setPosition(ccp(70, 150)); this->addChild(spr1); // 参数 图片名称 矩形区域 CCSprite * spr2 = CCSprite::create("Icon.png",CCRectMake(0, 0, 30, 30)); spr2->setPosition(ccp(150, 150)); this->addChild(spr2);//
阅读全文
解释cocos2dx的HelloWorldScene的类
摘要:在之前的AppDelegate中的 //这里可以换场景de // create a scene. it's an autorelease object CCScene *pScene = HelloWorld::scene(); // run pDirector->runWithScene(pScene);默认导演将Hello World 这个场景展示在模拟器中注释HelloWorldScene.h#ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__#include "cocos2d.h"..
阅读全文
第一个cocos2d-x 项目
摘要:熟悉4个常用的类CCSprite 精灵 游戏种角色 可以移动,缩放,旋转,动画 等。CCLayer 层 游戏基本都是层组合层的CCScene 场景 主界面关卡选择界面Loading界面游戏界面。。。。。。CCDirector 导演 主要负责不同的场景之间的切换 也可以控制整个游戏流程AppDelegatede 3个生命周期函数 1 //项目启动后入口函数 2 3 4 5 bool AppDelegate::applicationDidFinishLaunching() 6 7 { 8 9 //这两行是初始化导演 : 注意 一个游戏中只有一个导演10...
阅读全文
ios游戏编程之从零开始 - cocos2d-x 与cocos2d引擎游戏开发
摘要:cocos2d-x的主要特征:跨平台,免费开源,社区支持cocos2d-x的主要功能:基于OpenGL ES 渲染系统。动作, 动作序列,动作组合。场景切换粒子系统音效和背景音乐支持集成物理引擎Box—2D和Chipmunklua脚本支持
阅读全文
浙公网安备 33010602011771号