Fork me on GitHub
上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 125 下一页

2012年4月5日

摘要: In an earlier postCGRect, CGSize and CGPoint FunctionsI demonstrated a number of geometry structures available for representing a point (CGPoint – x and y coordinates), size (CGSize – height and width) and rectangles (CGRect – combination of both).Unfortunately, you cannot directly store any of the 阅读全文
posted @ 2012-04-05 15:27 pengyingh 阅读(285) 评论(0) 推荐(0)
摘要: 由于Box2D是不直接与鼠标交互的,而是通过鼠标关节b2MouseJoint交互的。交互的过程由四个步骤完成:第一步:获取鼠标单击处的刚体。第二步:创建鼠标关节。第三步:控制鼠标关节。第四步:销毁鼠标关节。首先,获取刚体。public function GetBodyAtMouse(includeStatic:Boolean=false):b2Body{// 在鼠标点击处创建一个极小区域,大小为0.002m*0.002mvar mousePVec:b2Vec2 = new b2Vec2(stage.mouseX/RATIO, stage.mouseY/RATIO);var aabb:b2AAB 阅读全文
posted @ 2012-04-05 15:24 pengyingh 阅读(1204) 评论(0) 推荐(0)
摘要: CCScene 对于使用cocos2d的童鞋肯定很熟悉,那么在使用CCScene *s = [CCScenenode];[s addChild: [restartAction() node]];[[CCDirectorsharedDirector]replaceScene:s]; 对scene进行场景(CCLayout)进行切换时,cocos2d提供了一些特效进行过渡,那么今天仔细翻开cocos2d源码,将所有的动画效果都测试了一遍,大概整理如下,提供大家查阅和使用吧; 因为我使用的是最新的cocos2d的1.0版本,所以一些函数方法跟之前不一样了,所以不要感到奇怪; 由于代码都有备注,所以就 阅读全文
posted @ 2012-04-05 15:21 pengyingh 阅读(602) 评论(0) 推荐(0)
摘要: 转自:http://flandycheng.blog.51cto.com/855176/571138通常调用某个动作的方法:1// 创建动作2idactionTo = [CCMoveTo actionWithDuration: 2 position:ccp(s.width-40, s.height-40)];34// 使用动作。(说明:tamara 是一个 CCSprite。)5[tamara runAction: actionTo];瞬时动作顾名思义。瞬时动作就是不需要时间,马上就完成的动作。瞬时动作的共同基类是 InstantAction。放置 – Place效果类似于 node.Posi 阅读全文
posted @ 2012-04-05 15:00 pengyingh 阅读(217) 评论(0) 推荐(0)
摘要: 将该图片放置到屏幕左下方CCSprite sprite = CCSprite.sprite("Default.png"); addChild(sprite); 生成的精灵放置在(0,0),也就是屏幕左下角。但是精灵的贴图的中心点和精灵的左下角位置一致,导致贴图只能显示一部分(贴图的右边上半部分)。可以这样想,一个精灵有两部分,一部分是节点背景对象,另一部分是贴图对象(自己理解定义的名称,非官方)怎么可以让贴图完全显示出来呢?使用定位点每个节点都有一个定位点,但是只有当节点拥有贴图时,这个定位点才有用。默认情况下,anchorPoint属性设置为(0.5,0.5)定位点和节点 阅读全文
posted @ 2012-04-05 14:04 pengyingh 阅读(14752) 评论(0) 推荐(1)
摘要: CCSpriteBatchNode *chapter2SpriteBatchNode; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"scene1atlas.plist"]; // 3.1 chapter2SpriteBatchNode = [CCSpriteBatchNode batchNodeWithFile:@"scene1atlas.png&q 阅读全文
posted @ 2012-04-05 12:00 pengyingh 阅读(130) 评论(0) 推荐(0)
摘要: 1- 直接加载图片文件作为frameCCAnimation *robotAnim = [CCAnimation animation]; // 4 [robotAnim addFrameWithFilename:@"an1_anim2.png"]; // 5 [robotAnim addFrameWithFilename:@"an1_anim3.png"]; [robotAnim addFrameWithFilename:@"an1_anim4.png"]; id robotAnimationAction = [CCAnimate ac 阅读全文
posted @ 2012-04-05 11:57 pengyingh 阅读(193) 评论(0) 推荐(0)
摘要: id action = [CCRepeatForever actionWithAction: [CCSequence actions: [CCDelayTime actionWithDuration:2.0f], [CCMoveTo actionWithDuration:0.01f position:position1], [CCScaleTo actionWithDuration:0.01f scale:0.5f], ... 阅读全文
posted @ 2012-04-05 11:22 pengyingh 阅读(288) 评论(0) 推荐(0)

2012年4月4日

摘要: 很多时候我们的程序操作结构都是UITabBarController+UINavigationController,每个UITabBarController item里面都有很多层的UINavigationController,而UITabBarController默认有一个事件就是双击UITabBarController item时,会把这个item里的UINavigationController pop 到root,而我们有时不希望一下子就pop到了根视图,因为可能还会有一些逐层处理功能需要完成。这个时候如果想屏闭掉这个双击事件只留下单击切换标签事件的话,就可以参考下面的方法重写UITabB 阅读全文
posted @ 2012-04-04 22:56 pengyingh 阅读(803) 评论(0) 推荐(0)
摘要: 状态栏是可以通过UIApplication类提供的一些方法来修改的,比如完全去掉状态栏或者修改风格,不过这些改变只是在你的程序内部,当你退出你的程序又会复原。UIApplication*myApp=[UIapplicationsharedApplication];1.隐藏状态栏[myAppsetStatusBarHidden:YESanimated:YES];记得隐藏状态栏后的你的“桌面”就增加320×20的大小,所以最好是在任何window或者view创建之前隐藏它。2.状态栏风格[myAppsetStatusBarStyle:UIStatusbarStyleBlackOpaque 阅读全文
posted @ 2012-04-04 22:54 pengyingh 阅读(418) 评论(0) 推荐(0)
上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 125 下一页

导航