<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                1.CCNode節點類的屬性 ~~~ //錨點-------------------------------- CCLabelTTF *lifeLabel = [CCLabelTTF labelWithString:@"生命值:" fontName:@"Arial" fontSize:20]; //錨點設置 lifeLabel.anchorPoint = CGPointMake(1, 1); //把postion 點作為label的左上角 lifeLabel.position = ccp(120, winSize.height - 120); [self addChild:lifeLabel z:10]; CCLabelTTF *lifeLabel2 = [CCLabelTTF labelWithString:@"生命值2:" fontName:@"Arial" fontSize:20]; //錨點設置 lifeLabel2.anchorPoint = CGPointMake(0.5, 0.5);//把postion 點作為label的幾何中心 lifeLabel2.position = ccp(120, winSize.height - 120); [self addChild:lifeLabel2 z:10]; CCLabelTTF *lifeLabel3 = [CCLabelTTF labelWithString:@"生命值3:" fontName:@"Arial" fontSize:20]; //錨點設置 lifeLabel3.anchorPoint = CGPointMake(0, 0);////把postion 點作為label的右下角 lifeLabel3.position = ccp(120, winSize.height - 120); [self addChild:lifeLabel3 z:10]; ~~~ ![](https://box.kancloud.cn/2016-08-22_57bab5585c038.jpg) ![](https://box.kancloud.cn/2016-08-22_57bab55875624.jpg) ~~~ //CCNode 節點類------------------- /*節點類的屬性 1.anchorPoint 錨點 2.camera 游戲視角 3d使用 3.children 子節點. (addchild:)children 為節點的子節點數組,變量類型是CCArray 4.contentSize //未轉化的節點大小,也就是本身的寬,高 :主要用于碰撞檢測 */ //得到精靈的矩形區域 CCLabelTTF *label = [CCLabelTTF labelWithString:@"sprite" fontName:@"Arial" fontSize:20]; label.position = ccp(100, 100); [self addChild:label]; CCSprite *sprite = [[CCSprite alloc]initWithFile:@"hero_1.png"]; sprite.position = ccp(50, 50); [self addChild:sprite]; //NSLog(@"%@",[self rectOfSprite:sprite]); NSLog(@"(%f,%f,%f,%f)",[self rectOfSprite:sprite].origin.x,[self rectOfSprite:sprite].origin.y,[self rectOfSprite:sprite].size.width,[self rectOfSprite:sprite].size.height); //(9.000000,-10.500000,82.000000,121.000000) ~~~ 得到精靈位置的類->用于碰撞檢測 ~~~ //這個矩形位置 是依賴 左下角作為原點進行的 - (CGRect)rectOfSprite:(CCSprite *)sprite { //依賴位置坐標和contentSize進行轉換,默認的錨點是 (0.5 ,0.5) return CGRectMake(sprite.position.x - sprite.contentSize.width/2, sprite.position.y - sprite.contentSize.height/2, sprite.contentSize.width, sprite.contentSize.height); } ~~~ 2.CCNode節點類的方法 1)子節點的處理 ~~~ //1.子節點的處理-------------- //1)創建一個node CCNode *node = [CCNode node]; //2增加一個子節點 CCNode *childNode = [CCNode node]; [node addChild:childNode z:10 tag:1]; //3使用tag獲得子節點 CCNode *tagNode = [node getChildByTag:1];//等于 childNode //4使用tag刪除子節點 [node removeChildByTag:1];//刪除了childNode //5通過節點指針刪除節點 [node removeChild:childNode cleanup:YES];//如果cleanup 為yes,則停止運行中的任何動作 //6刪除一個節點的所有節點 [node removeAllChildrenWithCleanup:YES]; //7從當前節點的父節點刪除當前節點 [childNode removeFromParentAndCleanup:YES]; ~~~ 2)子節點執行的動作 ~~~ //2執行動作 ----------------- id action = [CCAction action]; [action setTag:2]; //1運行action動作 [node runAction:action]; //2停止該節點的所有動作 [node stopAllActions]; //3停止某個特定的動作/依賴tag [node stopAction:action]; [node stopActionByTag:2]; //4獲取當前節點的某個特定動作 id tempAction = [node getActionByTag:2]; //5獲取某節點的所有動作的數量 int numberOfActions = [node numberOfRunningActions]; ~~~ 3)預定消息 ~~~ //3預定消息 //1)每幀都調用的更新方法 - (void)scheduleUpdates { [self scheduleUpdate]; } - (void)update:(ccTime)delta { //游戲中每一幀都將調用此方法 } //2)為消息安排優先級 從小到大開始執行,順序是 3-> 1 ->2 //1)每幀都調用的更新方法 - (void)scheduleUpdates1 { [self scheduleUpdate]; } - (void)scheduleUpdates2 { [self scheduleUpdateWithPriority:1]; } - (void)scheduleUpdates3 { [self scheduleUpdateWithPriority:-1]; } //3)指定運行特定的更新方法 并設置調用的時間間隔 - (void)scheduleUpdates4 { [self schedule:@selector(updateTenTimesPerSecond:) interval:0.1f]; } - (void)updateTenTimesPerSecond:(ccTime)delta { } ~~~ ~~~ //4)停止某個節點的某個指定選擇器,但是不會停止 預定的更新方法 [self unschedule:@selector(updateTenTimesPerSecond:)]; //如果停止預定的更新方法 [self unscheduleUpdate]; //5停止節點的所有選擇器,保羅 schduleupdate里設置的Update 選擇期.但是不會停止節點的動作 [self unscheduleAllSelectors]; //6)_cmd 關鍵字停止當前方法的預定 [self unschedule:_cmd]; ~~~ 4.其他的方法:(不完全) ~~~ //4.其他方法 //1) 獲取節點的邊框 CGRect spriteBound = [sprite boundingBox];//==rectOfSprite // //2)清除所有的動作和預定的方法 [sprite cleanup];// //坐標轉換.... //3)繪制自己的節點 // - (void)draw{}; //4)-(id)init 初始化方法 //5 - (void)onEnter 回調方法:當 CCNode 進入舞臺的時候調用 //6 - (void)onEnterTransitionDidFinished //帶有過渡效果的進入舞臺的時候調用 // - (void)OnExit //離開舞臺時候調用 ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看