摘要:该类已经把tableview封装好,可以把它当做一个精灵来用,这样做的好处是,当一个界面同时需要多个tableview的时候就可以很好的解决这个问题,而且模块也更清晰。//-----------------------------------------------------------------//@file gameui/Card/CardSlip.h//@date 2014-01-03//@desc 我的卡组滑动界面//@action 我的卡组系统 //------------------------------------------...
阅读全文
随笔分类 - cocos2d-x
摘要:strPath = g_ImgPath + "方正卡通简体.ttf"; m_pLebGold = CCLabelTTF::create("999999999", strPath.c_str(), 30); CC_ERROR(m_pLebGold, "[CGameMainUI::onEnterTransitionDidFinish] m_pLebGold 为空") m_pLebGold->setPosition(ccp(60, 70)); m_pLebGold->setAnchorPoint(CCPointZero); th
阅读全文
摘要:1.假设文本框所在的父控件所能容纳的最大字体号为28,那么将字体设置为28,在适当缩放,这样字体就会比较清晰,否则真机测试的时候会很模糊不清晰。2.凡是要写在代码中的,都要将交互项选中。
阅读全文
摘要:#ifndef __TABLEVIEWTESTSCENE_H__#define __TABLEVIEWTESTSCENE_H__#include "cocos2d.h"#include "cocos-ext.h"void runTableViewTest();class TableViewTestLayer : public cocos2d::CCLayer, public cocos2d::extension::CCTableViewDataSource, public cocos2d::extension::CCTableViewDelegate{p
阅读全文
摘要:#include "../CCControlScene.h"class CCControlSliderTest : public CCControlScene{public: CCControlSliderTest(); virtual ~CCControlSliderTest(); bool init(); void valueChanged(CCObject *sender, CCControlEvent controlEvent);protected: CCLabelTTF* m_pDisplayValueLabel; CONTROL_SCENE_CR...
阅读全文
摘要:#ifndef __CCCONTROLSCENE_H__#define __CCCONTROLSCENE_H__#include "cocos2d.h"#include "cocos-ext.h"USING_NS_CC;USING_NS_CC_EXT;//创建层的同时赋值标题#define CONTROL_SCENE_CREATE_FUNC(controlScene) \public: \static CCScene* sceneWithTitle(const char * title) \{ \ CCScene* pScene = CCScene::c
阅读全文
摘要://类的定义#ifndef __NOTIFICATIONCENTERTEST_H__#define __NOTIFICATIONCENTERTEST_H__#include "cocos2d.h"class NotificationCenterTest : public cocos2d::CCLayer{public: NotificationCenterTest(); void toExtensionsMainLayer(cocos2d::CCObject* sender); void toggleSwitch(cocos2d::CCObject *sender); ..
阅读全文
摘要:const std::string testsName[MAX_COUNT] = { "Bug-350", "Bug-422", "Bug-458", "Bug-624", "Bug-886", "Bug-899", "Bug-914", "Bug-1159", "Bug-1174"};void ExtensionsMainLayer::onEnter(){ CCLayer::onEnter(); CCSize s
阅读全文
摘要:引擎提供了CCGLProgram类来处理着色器相关操作,对当前绘图程序进行了封装,其中使用频率最高的应该是获取着色器程序的接口:constGLuintgetProgram();该接口返回了当前着色器程序的标识符。后面将会看到,在操作OpenGL的时候,我们常常需要针对不同的着色器程序作设置。注意,这里返回的是一个无符号整型的标识符,而不是一个指针或结构引用,这是OpenGL接口的一个风格。对象(纹理、着色器程序或其他非标准类型)都是使用整型标识符来表示的。CCGLProgram提供了两个函数导入着色器程序,支持直接从内存的字符串流载入或是从文件中读取。这两个函数的第一个参数均指定了顶点着色器,
阅读全文
摘要:#ifndef __MUTITOUCHTEST_H__#define __MUTITOUCHTEST_H__#include "../testBasic.h"class MutiTouchTestLayer : public CCLayer{public: bool init(); virtual void registerWithTouchDispatcher(void); virtual void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); virtual void ccTo..
阅读全文
摘要:#ifndef __CCDICTIONARY_H__#define __CCDICTIONARY_H__//需要哈希表的支持#include "support/data_support/uthash.h"#include "CCObject.h"#include "CCArray.h"#include "CCString.h"//Cocos2d命名空间NS_CC_BEGIN//声明一下CCDictionary类,因为CCDictElement要用到CCDictionary指针。class CCDictionary;
阅读全文
摘要:CCSprite* pSprite = CCSprite::spriteWithFile("grossini.png");pSprite->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, CCDirector::sharedDirector()->getWinSize().height / 2));this->addChild(pSprite,1,1001);pSprite->runAction(CCOrbitCamera::create(0.5f, 2
阅读全文
摘要:CCSize s = CCDirector::sharedDirector()->getWinSize(); CCNode* explosion = CCParticleSun::create(); ((CCParticleSun*)explosion)->setTexture(CCTextureCache::sharedTextureCache()->addImage("fire.png")); explosion->setPosition( ccp(s.width/2, s.height/2) ); addChild(...
阅读全文
摘要:Test6::Test6(){ CCSprite* sp1 = CCSprite::create(s_pPathSister1); CCSprite* sp11 = CCSprite::create(s_pPathSister1); CCSprite* sp2 = CCSprite::create(s_pPathSister2); CCSprite* sp21 = CCSprite::create(s_pPathSister2); sp1->setPosition(ccp(100,160)); sp2->setPosition(ccp(380...
阅读全文
摘要:Test5::Test5(){ CCSprite* sp1 = CCSprite::create(s_pPathSister1); CCSprite* sp2 = CCSprite::create(s_pPathSister2); sp1->setPosition(ccp(100,160)); sp2->setPosition(ccp(380,160)); CCRotateBy* rot = CCRotateBy::create(2, 360); CCActionInterval* rot_back = rot->reverse(); CCAc...
阅读全文
摘要:Test4::Test4(){ CCSprite *sp1 = CCSprite::create(s_pPathSister1); CCSprite *sp2 = CCSprite::create(s_pPathSister2); sp1->setPosition( ccp(100,160) ); sp2->setPosition( ccp(380,160) ); addChild(sp1, 0, 2); addChild(sp2, 0, 3); //在第二秒的时候执行delay2函数 schedule( schedule_sel...
阅读全文
摘要:void Test2::onEnter(){ TestCocosNodeDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCSprite *sp1 = CCSprite::create(s_pPathSister1); CCSprite *sp2 = CCSprite::create(s_pPathSister2); CCSprite *sp3 = CCSprite::create(s_pPathSister1); CCSprite *sp4 = CCSp...
阅读全文
摘要:#ifndef _DRAW_PRIMITIVES_TEST_H_#define _DRAW_PRIMITIVES_TEST_H_////----#include "cocos2d.h"#include "../testBasic.h"class DrawPrimitivesTest : public CCLayer{public: DrawPrimitivesTest(); virtual void draw();//必须重写这个函数,画图要在这函数中画};class DrawPrimitivesTestScene : public TestScene{
阅读全文
摘要:void MotionStreakTest1::onEnter(){ MotionStreakTest::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); // the root object just rotates around m_root = CCSprite::create(s_pPathR1); addChild(m_root, 1); m_root->setPosition(ccp(s.width/2, s.height/2)); // the ta...
阅读全文
摘要://创建类的对象,并返回相应类的指针/** * define a create function for a specific type, such as CCLayer * @__TYPE__ class type to add create(), such as CCLayer */#define CREATE_FUNC(__TYPE__) \static __TYPE__* create() \{ \ __TYPE__ *pRet = new __TYPE__(); \ if (pRet && pRet->init()) \ { \ pRet->autor..
阅读全文