随笔分类 - 游戏编程 之 从零开始(2.2.0)
本类文章 均以 2.2.0 版本 为标准
摘要:3.20 内存及效率的一些总结3.21 设置竖屏1、androidAndroidManifest.xml文件中,screenOrientation="landscape" 为横屏,screenOrientation="portrait"为竖屏2、IOS-(NSUInteger)supportedInterfaceOrientations{ #ifdef__IPHONE_6_0 //横屏显示 //returnUIInterfaceOrientationMaskLandscape; //竖屏显示 returnUIInterfaceOrientationMas
阅读全文
摘要:CCProgressTimer * pross = CCProgressTimer::create(CCSprite::create("Icon.png")); pross->setPosition(ccp(100,180)); //设置进度条的样式 扇形 pross->setType( kCCProgressTimerTypeRadial); //设置进度值范围[0,100] pross->setPercentage(100); //反进度计时 pross->setReverseProgress...
阅读全文
摘要:3.16 drawvirtual void draw();void HelloWorld::draw(){ CCSize size = CCDirector::sharedDirector()->getWinSize(); //【设置颜色】 ccDrawColor4B(255,0,0,255); //【设置线条的宽度】 glLineWidth(2); //【绘制一条直线】 ccDrawLine(ccp(10,10),ccp(size.width/2,size.height/2)); ccDrawColor4B(255,255,0,255); ...
阅读全文
摘要://示例代码/* typedef enum LanguageType { kLanguageEnglish = 0, kLanguageChinese, kLanguageFrench, kLanguageItalian, kLanguageGerman, //德语 kLanguageSpanish, //西班牙语 kLanguageRussian, kLanguageK...
阅读全文
摘要:/* *bool hasMoved(); 这里获取的不是开关是否正在被用户拨动,而是开关最终的状态是由用户手动拨动开关进行的, *还是用户点击开关进行的状态更改 */ CCControlSwitch* pSwitch = CCControlSwitch::create( CCSprite::create("switch-mask.png"), CCSprite::create("switch-on.png"), CCSprite::create("switch-off.pn...
阅读全文
摘要:EditBox 创建添加 以及 一些函数参数的解析#include "GUI/CCEditBox/CCEditBox.h"#include "GUI/CCControlExtension/CCScale9Sprite.h"#include "cocos-ext.h"USING_NS_CC;USING_NS_CC_EXT;CCScale9Sprite* spr = CCScale9Sprite::create("Icon.png"); CCEditBox* box = CCEditBox::create(CCSize
阅读全文
摘要://继承(class HelloWorld : public cocos2d::CCLayer, public cocos2d::CCTextFieldDelegate) CCTextFieldTTF* textField = CCTextFieldTTF::textFieldWithPlaceHolder("Click input...", "Helvetica", 24); textField->setPosition(ccp(size.width*0.5,size.height*0.7)); addChild(textField); ...
阅读全文
摘要:cocos2d-x version 2.2.0首先,在 HelloWorldScene.cpp 中的 init()函数中 添加如下代码 (资源文件可以直接到 cocos2d-x 中获取)#include "CCArmature/utils/CCArmatureDataManager.h" //(头文件添加)//! create a new thread to load data(异步加载) /** * @brief Add ArmatureFileInfo, it is managed by CCArmatureDataManager. * It ...
阅读全文
摘要:3.4 常用的两种 layer 层//在cocos2d-x中,经常使用到的两种 layer 层 : CCLayer 和 CCLayerColor //CCLayer 的创建 CCLayer* layer = CCLayer::create(); //CCLayerColor 的创建 CCLayerColor* layerColor = CCLayerColor::create(const cocos2d::ccColor4B &color); //RGBO /* 注意: 新创建的 CCLayer 和 CCLayerColor 层如果没有手动设置...
阅读全文
摘要:3.3.1 创建精灵常用的 4 种方式 (当然还有其他方式,只不过 这四种比较常用)//创建精灵常用的 4 种方式 CCSprite* spr1 = CCSprite::create(const char* pszFileName); //作用:通过一张图片生成精灵对象 //参数:图片名称 CCSprite* spr2 = CCSprite::create(const char* pszFileName, const cocos2d::CCRect& rect); //作用:通过一张图片进行指定区域裁剪后,生成精灵对象 //参数 1:图片名称 //参数...
阅读全文
摘要:HelloWorldScene.h#ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__#include "cocos2d.h"#include "Box2D/Box2D.h"#include "SimpleAudioEngine.h"class HelloWorld : public cocos2d::CCLayer{public: // Here's a difference. Method 'init' in cocos2d-x retur
阅读全文
摘要:Classed/AppDelegate.cpp 文件内容如下:#include "cocos2d.h"#include "CCEGLView.h"#include "AppDelegate.h"#include "HelloWorldScene.h"#include "SimpleAudioEngine.h"using namespace CocosDenshion;USING_NS_CC;AppDelegate::AppDelegate(){}AppDelegate::~AppDelegate
阅读全文

浙公网安备 33010602011771号