位置: 编程技术 - 正文
推荐整理分享如何在COCOS2D中绘制3d椭圆柱?(cocos2d教程),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:cocos2d怎么用,cocos2djs,cocos2d怎么样,cocos2djs,cocos2d-x教程,cocos2dx怎么用,cocos2djs,cocos2d怎么用,内容如对您有帮助,希望把文章链接给更多的朋友!
将以下代码添加到CCActionGrid3D.h
class CC_DLL CCEllipse3D : public CCGrid3DAction
{public: /** initializes an action with duration, grid size, waves and amplitude */ bool initWithDuration(float duration, const CCSize& gridSize, float alength, float blength, float startangle, float endagnle,float xoffset,float yoffset); /** * @js NA * @lua NA */ virtual CCObject* copyWithZone(CCZone* pZone); virtual void update(float time);public: /** creates an action with duration, grid size, waves and amplitude */ static CCEllipse3D* create(float duration, const CCSize& gridSize, float alength, float blength, float startangle, float endagnle,float xoffset,float yoffset);protected:float m_fStartAngle;//开始角float m_fEndAngle;//结束角float m_fALength;//长轴float m_fBLength;//短轴float m_fXOffset;//X偏移float m_fYOffset;//Y偏移};
将以下代码添加到CCActionGrid3D.cpp
CCEllipse3D* CCEllipse3D::create(float duration, const CCSize& gridSize, float alength, float blength, float startangle, float endagnle,float xoffset,float yoffset){CCEllipse3D *pAction = new CCEllipse3D();if (pAction){if (pAction->initWithDuration(duration, gridSize, alength, blength, startangle, endagnle, xoffset, yoffset)){pAction->autorelease();}else{CC_SAFE_RELEASE_NULL(pAction);}}return pAction; }bool CCEllipse3D::initWithDuration(float duration, const CCSize& gridSize, float alength, float blength, float startangle, float endagnle,float xoffset,float yoffset){if (CCGrid3DAction::initWithDuration(duration, gridSize)){m_fStartAngle = startangle;//开始角m_fEndAngle = endagnle;//结束角m_fALength = alength;//长轴m_fBLength = blength;//短轴m_fXOffset = xoffset;//X偏移m_fYOffset = yoffset;//Y偏移return true;}return false;}CCObject* CCEllipse3D::copyWithZone(CCZone *pZone){CCZone* pNewZone = NULL;CCEllipse3D* pCopy = NULL;if(pZone && pZone->m_pCopyObject) {//in case of being called at sub classpCopy = (CCEllipse3D*)(pZone->m_pCopyObject);}else{pCopy = new CCEllipse3D();pZone = pNewZone = new CCZone(pCopy);}CCGrid3DAction::copyWithZone(pZone);pCopy->initWithDuration(m_fDuration, m_sGridSize, m_fALength, m_fBLength,m_fStartAngle,m_fEndAngle,m_fXOffset,m_fYOffset);CC_SAFE_DELETE(pNewZone);return pCopy;}void CCEllipse3D::update(float time){ int i, j; for (i = 0; i < m_sGridSize.width1; i){float angle = (m_fStartAngle (m_fEndAngle-m_fStartAngle)*i/m_sGridSize.width)*time;for (j = 0; j < m_sGridSize.height 1; j){ccVertex3F v = originalVertex(ccp(i ,j));v.x = m_fALength*cos(angle)-m_fALengthm_fXOffset; v.y = m_fBLength*sin(angle) v.y m_fYOffset; setVertex(ccp(i, j), v);} } }
调用相关方法:
runAction(CCEllipse3D::create(1.0f, CCSize(,1) ,.0f,-.0f,0.0f,(float)M_PI,.0f,-.0f));
第一个参数代表时间
第二个参数代表网
第三个参数椭圆长轴
第四个参数椭圆短柱
第五个参数开始绘制角
第六个参数结束绘制角
第七个参数x轴偏移
第八个参数Y轴偏移
SpriteBuilder Demo学习笔记 1、资源的auto-scaling。只需提供最高级别的resolution,SpriteBuilder会自动生成低级别的。SpriteBuilder默认是从4x(两倍于Retina屏)开始scaling,可以在File-ProjectS
cocos2d3.x在win7的环境配置和安装 安装过程:1:安装VS(需要IE.0以上)2:安装python2.7.9一直下一步即可;3:安装完python后右键我的电脑-属性-高级系统设-系统变量找到Path编辑,最
lua学习系列一之配置环境与IDE 之所以想要学习lua是因为cocos官方出了一个基于eclipse的IDE,电脑装VS一直装不上去,苦于程序太多于是没有重装系统,最近才发现出现了这个IDE,心
标签: cocos2d教程
本文链接地址:https://www.jiuchutong.com/biancheng/369112.html 转载请保留说明!友情链接: 武汉网站建设