将"Cocos2d-x 精灵碰撞检测(方法一)" update函数修改一下。
使用精灵boundingBox函数获取直接精灵边界框, 不用自己计算精灵矩形大小了,还比较精确,然后调用intersectsRect计算2个精灵矩形是否存在集。
代码:
void HelloWorld::update(float delta)
{
//返回精灵边界框
CCRect cr1 = sp1->b...
分类:
其他好文 时间:
2014-06-07 01:44:56
阅读次数:
187
移动:
-(void) touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint touchLoc = [touch locationInNode:self];
// Log touch location
CCLOG(@"Moved sprite to @ %@",NSStringFromCGPo...
分类:
移动开发 时间:
2014-06-05 08:30:44
阅读次数:
352
声明函数碰撞检测函数,两个精灵和重写update
bool isCollision( CCPoint p1,CCPoint p2,int w1,int h1,int w2,int h2 );
CCSprite *sp2;
CCSprite *sp1;
virtual void update(float delta);
//重写触摸事件
virtual void regi...
分类:
其他好文 时间:
2014-06-05 07:12:15
阅读次数:
236
void HelloWorld::ccTouchMoved(cocos2d::CCTouch *touch, cocos2d::CCEvent *event)
{
CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();
if (m_ship) {
CCPoint pos = touch->getDelta...
分类:
移动开发 时间:
2014-06-05 05:25:10
阅读次数:
222
3.Actions-Basic:此demo中体现ccp由Point代替
①ActionManual:直接设置精灵的属性demo。
const Color3B Color3B::RED (255, 0, 0);
const Color3B Color3B::GREEN ( 0, 255, 0);
const Color3B Color3B::BLUE ( 0, ...
分类:
其他好文 时间:
2014-06-05 03:49:02
阅读次数:
225
有两个QLabel, 一个显示静态图片, 一个显示动态图片, 相互切换显示 .....
分类:
其他好文 时间:
2014-06-05 02:42:59
阅读次数:
223
菜单主页面:
主菜单页面背景
CCSprite* bg = CCSprite::create("MainMenu.png");
bg->setScale(0.5);
bg->setPosition( ccp(size.width/2, size.height/2) );
this->addChild(bg, 0,0);
菜单按钮及其效果,单击事件...
分类:
其他好文 时间:
2014-06-05 00:55:52
阅读次数:
437
针对2.x1、CCSprite无法直接用文件名更换图片,可以添加如下函数bool
CCSprite::setWithFile(const char *pszFilename){ CCAssert(pszFilename != NULL,
"Invalid filename for sprite")....
分类:
其他好文 时间:
2014-06-02 20:41:58
阅读次数:
325
附件中是一款翻书效果插件,由于附件上传大小限制,在下载完后,需要在megaFierstext_BHYF\Assets\Resources\Textures下添加图片精灵并修改属性为Texture,即可运行看效果。好多论坛上需要用币买,也减少了搜索时间,拿来就可以用。源码
分类:
其他好文 时间:
2014-05-31 11:50:00
阅读次数:
257
1:找到已安装FlashPaper目录下的子目录Interface下的文件DefaultViewer2.swf,在此swf文件的基础上实现自己的修改。2:利用swf反编译工具,这里推荐
硕思闪客精灵(SWFDecompiler),保存SWFDecompiler反编译过的.fla文件。3:利用fals...
分类:
其他好文 时间:
2014-05-29 14:24:08
阅读次数:
282