文章分类 -  Cocos2d-x探究

摘要:class CC_DLL CCNode : public CCObject{public: /// @{ /// @name Constructor, Distructor and Initializers /** * Default constructor */ CCNode(void); /** * Default destructor */ virtual ~CCNode(void); /** * Initializes the instance of CCNode * ... 阅读全文
posted @ 2013-10-07 12:57 walkabc 阅读(766) 评论(0) 推荐(0)
摘要:不多说,上源码,setFrameSize这个函数大家都比较熟悉吧,没错,main函数中的关键函数,定义了游戏窗口的大小,但是它可不只是定义窗口大小的。void CCEGLView::setFrameSize(float width, float height){ bool eResult = false; int u32GLFWFlags = GLFW_WINDOW; //create the window by glfw. //check CCAssert(width!=0&&height!=0, "invalid window's size equal 0 阅读全文
posted @ 2013-07-01 23:39 walkabc 阅读(624) 评论(0) 推荐(0)
摘要:太晚了,先放上源码再说。 #include "Paddle.h"Paddle::Paddle(void){}Paddle::~Paddle(void){}CCRect Paddle::rect(){ CCSize s = getTexture()->getContentSize(); return CCRectMake(-s.width / 2, -s.height / 2, s.width, s.height);}Paddle* Paddle::paddleWithTexture(CCTexture2D* aTexture){ Paddle* pPaddle = n 阅读全文
posted @ 2013-07-01 00:28 walkabc 阅读(333) 评论(0) 推荐(0)
摘要:每个Node对象都要一个protected的指针变量m_pScheduler,这个指针指向的是director->getScheduler();有源码证明 1 CCNode::CCNode(void) 2 : m_fRotationX(0.0f) 3 , m_fRotationY(0.0f) 4 , m_fScaleX(1.0f) 5 , m_fScaleY(1.0f) 6 , m_fVertexZ(0.0f) 7 , m_obPosition(CCPointZero) 8 , m_fSkewX(0.0f) 9 , m_fSkewY(0.0f)10 , m_obAnchorPointI. 阅读全文
posted @ 2013-06-30 15:03 walkabc 阅读(425) 评论(0) 推荐(0)
摘要:1.窗口:这就不用解释了吧2.视口:就是窗口中用来显示图形的一块矩形区域,它可以和窗口等大,也可以比窗口大或者小。只有绘制在视口区域中的图形才能被显示,如果图形有一部分超出了视口区域,那么那一部分是看不到的。通过glViewport()函数设置。如下图所示: 图1. 不同大小的视口3.裁剪区域(平行投影):就是视口矩形区域的最小最大x坐标(left,right)和最小最大y坐标(bottom,top),而不是窗口的最小最大x坐标和y坐标。通过glOrtho()函数设置,这个函数还需指定最近最远z坐标,形成一个立体的裁剪区域。 阅读全文
posted @ 2013-06-30 00:13 walkabc 阅读(871) 评论(0) 推荐(0)
摘要:#include "main.h"#include "../Classes/AppDelegate.h"#include "cocos2d.h"#include #include #include #include USING_NS_CC;// 500 is enough?#define MAXPATHLEN 500int main(int argc, char **argv){ // get application path int length; char fullpath[MAXPATHLEN]; length = readli 阅读全文
posted @ 2013-06-29 22:45 walkabc 阅读(292) 评论(0) 推荐(0)
摘要:#include "AppDelegate.h"#include "HelloWorldScene.h"#include "AppMacros.h"USING_NS_CC;/**应用程序代表*/AppDelegate::AppDelegate() {}AppDelegate::~AppDelegate() {}/** * 这个方法会被CCApplication::sharedApplication()->run()调用 * */bool AppDelegate::applicationDidFinishLaunching() { 阅读全文
posted @ 2013-06-29 22:35 walkabc 阅读(264) 评论(0) 推荐(0)
摘要:#ifndef __CC_APPLICATION_PROTOCOL_H__#define __CC_APPLICATION_PROTOCOL_H__NS_CC_BEGINenum TargetPlatform{ kTargetWindows, kTargetLinux, kTargetMacOS, kTargetAndroid, kTargetIphone, kTargetIpad, kTargetBlackBerry,};/** * @addtogroup platform * @{ */class CC_DLL CCApplicationProto... 阅读全文
posted @ 2013-06-29 22:24 walkabc 阅读(314) 评论(0) 推荐(0)
摘要:Cocos2d-x的帧频系统默认是60帧每秒。View Code 1 /**这里返回的单位是按毫秒计算,这个时间的WallClock时间,即1970_1_1到现在的时间差*/2 static long getCurrentMillSecond() {3 long lLastTime;4 struct timeval stCurrentTime;5 6 gettimeofday(&stCurrentTime,NULL);7 lLastTime = stCurrentTime.tv_sec*1000+stCurrentTime.tv_usec*0.001; //mi... 阅读全文
posted @ 2013-05-07 00:24 walkabc 阅读(350) 评论(0) 推荐(0)