public static CCLayerMultiplex layerWithLayer(CCLayer layer) { CCLayerMultiplex multiplex = new CCLayerMultiplex(); multiplex.initWithLayer(layer); return(multiplex); }
public void runing(CCLayer cclayer) { #region Sprite跑动动画 CCSize s = CCDirector.sharedDirector().getWinSize(); // 创建批处理节点,读取plist文件 CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("plist/images/wolf_move");//批处理节点贴图 cclayer.addChild(batch, 0, 1); CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("plist/wolf_move");//读取plsit文件 //起始精灵 this.initWithSpriteFrameName("wolf_move1.png"); this.position = (new CCPoint(s.width / 3, s.height / 2)); batch.addChild(this); // 创建逐帧数组 List<CCSpriteFrame> animFrames = new List<CCSpriteFrame>(); string str = ""; for (int i = 2; i < 8; i++) { string temp = ""; temp = i.ToString(); str = string.Format("wolf_move{0}.png", temp); CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str); animFrames.Add(frame); } //动画Animate CCAnimation animation = CCAnimation.animationWithFrames(animFrames, 0.2f);//Animation动画信息 this.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithAnimation(animation, false)));//执行动画 #endregion }
/// <summary> /// * lua script can not init with undetermined number of variables /// * so add these functinons to be used with lua. /// </summary> /// <param name="layer"></param> /// <returns></returns> public static CCLayerMultiplex LayerWithLayer(CCLayer layer) { var pMultiplexLayer = new CCLayerMultiplex(); pMultiplexLayer.InitWithLayer(layer); //pMultiplexLayer->autorelease(); return pMultiplexLayer; }
public StressTest2() { CCSize s = CCDirector.SharedDirector.WinSize; CCLayer sublayer = new CCLayer(); CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); sp1.Position = (new CCPoint(80, s.Height / 2)); CCActionInterval move = new CCMoveBy (3, new CCPoint(350, 0)); CCActionInterval move_ease_inout3 = new CCEaseInOut((CCActionInterval) (move.Copy()), 2.0f); var move_ease_inout_back3 = (CCActionInterval) move_ease_inout3.Reverse(); CCFiniteTimeAction seq3 = CCSequence.FromActions(move_ease_inout3, move_ease_inout_back3); sp1.RunAction(new CCRepeatForever ((CCActionInterval) seq3)); sublayer.AddChild(sp1, 1); CCParticleFire fire = CCParticleFire.Create(); fire.Texture = (CCTextureCache.SharedTextureCache.AddImage("Images/fire")); fire.Position = (new CCPoint(80, s.Height / 2 - 50)); var copy_seq3 = (CCActionInterval) (seq3.Copy()); fire.RunAction(new CCRepeatForever (copy_seq3)); sublayer.AddChild(fire, 2); Schedule((shouldNotLeak), 6.0f); AddChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1); }
/// <summary> /// * lua script can not init with undetermined number of variables /// * so add these functinons to be used with lua. /// </summary> /// <param name="layer"></param> /// <returns></returns> public static CCLayerMultiplex layerWithLayer(CCLayer layer) { CCLayerMultiplex pMultiplexLayer = new CCLayerMultiplex(); pMultiplexLayer.initWithLayer(layer); //pMultiplexLayer->autorelease(); return(pMultiplexLayer); }
public virtual bool initWithLayer(CCLayer layer) { m_pLayers = new List<CCLayer>(1); m_pLayers.Add(layer); m_nEnabledLayer = 0; this.addChild(layer); return true; }
public virtual bool initWithLayer(CCLayer layer) { m_pLayers = new List <CCLayer>(1); m_pLayers.Add(layer); m_nEnabledLayer = 0; this.addChild(layer); return(true); }
public bool InitWithLayer(CCLayer layer) { m_pLayers = new List<CCLayer>(1); m_pLayers.Add(layer); m_nEnabledLayer = 0; AddChild(layer); return true; }
public override void runThisTest() { CCLayer pLayer = nextTextInputTest(); addChild(pLayer); CCDirector.sharedDirector().replaceScene(this); }
public Bomb(CCLayer layer) { Random rnd = new Random(); float posionX = 100 * (float)rnd.Next(1, 4);//Gold起始位置X坐标值 this.initWithFile("img/Wolf/Others/bomb"); this.position = new CCPoint(posionX, 850);//Gold起始位置 layer.addChild(this); this.runAction(CCMoveTo.actionWithDuration(5.0f, new CCPoint(posionX, -50)));//运动,垂直向下运动 }
public static new CCLayer node() { CCLayer ret = new CCLayer(); if (ret.init()) { return ret; } return null; }
public static new CCLayer node() { CCLayer cCLayer = new CCLayer(); if (cCLayer.init()) { return(cCLayer); } return(null); }
public static new CCLayer node() { CCLayer ret = new CCLayer(); if (ret.init()) { return(ret); } return(null); }
public void OnClick(CCLayer p_Layer) { p_Layer.isTouchEnabled = false; runAction(SayAction); runAction(action); ActionHelper.AsyncActionCallBack( action, ((sender, e) => { p_Layer.isTouchEnabled = true; })); }
public GroundBase(int typeId, CCPoint position, CCLayer layer) { this.GroundType = typeId; string imgPath = GetRoleImgPathByRoleTypeId(typeId); Row = (int)position.y; Col = (int)position.x; if (!string.IsNullOrEmpty(imgPath)) { Sprite = CCSprite.spriteWithFile(imgPath); Sprite.position = new CCPoint(position.x * AppContext.MAP_WIDTH + 15, position.y * AppContext.MAP_WIDTH + 15); layer.addChild(Sprite); } }
/// <summary> /// AddTitleMenu only text /// </summary> /// <param name="p_Layer">current CCLayer</param> /// <param name="p_TitleText">show text</param> /// <param name="y">current y</param> public static void AddTitleMenu(CCLayer p_Layer, String p_TitleText, ref float y) { CCLabelTTF label = CCLabelTTF.labelWithString(p_TitleText, "ChineseTitle", 28); label.Color = new ccColor3B(Color.White); CCMenuItemLabel tab = CCMenuItemLabel.itemWithLabel(label); CCMenu menu = CCMenu.menuWithItems(tab); menu.position = new CCPoint(CCDirector.sharedDirector().displaySizeInPixels.width / 2, y); //menu.position.y = p_CurrPoint.y; y -= tab.contentSize.height + Blank; p_Layer.addChild(menu); }
public SchedulerTest1() { CCLayer layer = new CCLayer(); //UXLOG("retain count after init is %d", layer->retainCount()); // 1 AddChild(layer, 0); //UXLOG("retain count after addChild is %d", layer->retainCount()); // 2 layer.Schedule((doSomething)); //UXLOG("retain count after schedule is %d", layer->retainCount()); // 3 : (object-c viersion), but win32 version is still 2, because CCTimer class don't save target. layer.Unschedule((doSomething)); //UXLOG("retain count after unschedule is %d", layer->retainCount()); // STILL 3! (win32 is '2') }
public Role(string roleImgPath, CCPoint position, CCLayer layer, Map map) { this.map = map; this.layer = layer; Col = (int)position.x; Row = (int)position.y; if (!string.IsNullOrEmpty(roleImgPath)) { Sprite = CCSprite.spriteWithFile(roleImgPath); Sprite.position = new CCPoint(position.x * AppContext.MAP_WIDTH + 15, position.y * AppContext.MAP_WIDTH + 15); layer.addChild(Sprite); } OringinGround = map.GroundList[Row * Map.Width + Col]; GetPathNodeList(); }
public void OnClick(CCLayer p_Layer) { p_Layer.isTouchEnabled = false; p_Layer.addChild(ResultPeople); ResultPeople.Play((obj) => { p_Layer.removeChild(ResultPeople,true); if (IsAnswer) { SceneController.RunScene(EnumScene.Question); } else { p_Layer.isTouchEnabled = true; } }); }
public Map(CCLayer layer) { this.layer = layer; GroundBase ground = null; GroundList = new List<GroundBase>(); for (int row = 0; row < Height; row++) { for (int col = 0; col < Width; col++) { ground = new GroundBase(Data[row, col], new CCPoint(col, row), layer); if (ground.Sprite != null) { ground.Sprite.tag = row * Width + col; } GroundList.Add(ground); } } }
public override void onEnter() { base.onEnter(); ccColor4B _ccColor4B = new ccColor4B(0, 0, 0, 0); CCSize winSize = CCDirector.sharedDirector().getWinSize(); CCLayer cCLayer = new CCLayer(); CCRenderTexture cCPoint = CCRenderTexture.renderTextureWithWidthAndHeight((int)winSize.width, (int)winSize.height); if (cCPoint == null) { return; } cCPoint.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f); cCPoint.position = new CCPoint(winSize.width / 2f, winSize.height / 2f); cCPoint.anchorPoint = new CCPoint(0.5f, 0.5f); cCPoint.begin(); this.m_pInScene.visit(); cCPoint.end(); CCRenderTexture cCRenderTexture = CCRenderTexture.renderTextureWithWidthAndHeight((int)winSize.width, (int)winSize.height); cCRenderTexture.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f); cCRenderTexture.position = new CCPoint(winSize.width / 2f, winSize.height / 2f); cCRenderTexture.anchorPoint = new CCPoint(0.5f, 0.5f); cCRenderTexture.begin(); this.m_pOutScene.visit(); cCRenderTexture.end(); ccBlendFunc _ccBlendFunc = new ccBlendFunc(1, 1); ccBlendFunc _ccBlendFunc1 = new ccBlendFunc(770, 771); cCPoint.Sprite.BlendFunc = _ccBlendFunc; cCRenderTexture.Sprite.BlendFunc = _ccBlendFunc1; cCLayer.addChild(cCPoint); cCLayer.addChild(cCRenderTexture); cCPoint.Sprite.Opacity = 255; cCRenderTexture.Sprite.Opacity = 255; CCFiniteTimeAction[] cCFiniteTimeActionArray = new CCFiniteTimeAction[] { CCFadeTo.actionWithDuration(this.m_fDuration, 0), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.hideOutShowIn)), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.finish)) }; CCAction cCAction = CCSequence.actions(cCFiniteTimeActionArray); cCRenderTexture.Sprite.runAction(cCAction); this.addChild(cCLayer, 2, 2147483647); }
/// <summary> /// /// </summary> /// <param name="p_Layer"></param> /// <param name="p_Text"></param> /// <param name="p_LeftButtonPic"></param> /// <param name="p_RightButtonPic"></param> /// <param name="y"></param> public static void AddSetMenu(CCLayer p_Layer, String p_Text, String p_LeftButtonPic, String p_RightButtonPic, SEL_MenuHandler p_LeftHandle,SEL_MenuHandler p_RightHandle, ref float y) { CCLabelTTF language = CCLabelTTF.labelWithString(p_Text, "ChineseTitle", 28); language.Color = new ccColor3B(Color.White); CCMenuItemLabel tab1 = CCMenuItemLabel.itemWithLabel(language); //CCTexture2D cctext2D1 = Media.PictureManager.GetCCTexture2D(p_LeftButtonPic); //CCSprite sprite1 = CCSprite.spriteWithTexture(cctext2D1); CCMenuItemSprite tab2 = CCMenuItemImage.itemFromNormalImage(p_LeftButtonPic,null, p_Layer, p_LeftHandle); //CCTexture2D cctext2D2 = Media.PictureManager.GetCCTexture2D(p_RightButtonPic); // CCSprite sprite2 = CCSprite.spriteWithTexture(cctext2D2); CCMenuItemSprite tab3 = CCMenuItemImage.itemFromNormalImage(p_RightButtonPic, null, p_Layer, p_RightHandle); CCMenu p_Menu1 = CCMenu.menuWithItems(tab1); CCMenu p_Menu2 = CCMenu.menuWithItems(tab2); CCMenu p_Menu3 = CCMenu.menuWithItems(tab3); //position p_Menu2 float textwidth = tab1.contentSize.width < 40 ? 40 : tab1.contentSize.width; float displayCenter = CCDirector.sharedDirector().displaySizeInPixels.width / 2; float x2 = displayCenter - textwidth; float x1 = displayCenter; float x3 = displayCenter + textwidth; float y2=y+(tab1.contentSize.height-tab2.contentSize.height)/2; p_Menu2.position = new CCPoint(x2, y2); p_Menu1.position = new CCPoint(x1, y); p_Menu3.position = new CCPoint(x3, y2); p_Layer.addChild(p_Menu2); p_Layer.addChild(p_Menu1); p_Layer.addChild(p_Menu3); y -= tab2.contentSize.height + Blank; }
public virtual void addLayer(CCLayer layer) { Debug.Assert(m_pLayers != null); m_pLayers.Add(layer); }
public virtual void addLayer(CCLayer layer) { this.m_pLayers.Add(layer); }
/// <summary> /// ���µ÷� /// </summary> /// <param name="score"></param> private void UpdateScore(List<CCSprite> digitSprites, CCLayer scoreLayer, int score, bool playSound) { string scoreStr = score.ToString(); for (int i = digitSprites.Count; digitSprites.Count < scoreStr.Length; i++) { var tempDigit = CCSprite.spriteWithFile("imgs/score/" + scoreStr[i]); tempDigit.position = new CCPoint(i * tempDigit.contentSize.width, 0); digitSprites.Add(tempDigit); scoreLayer.addChild(tempDigit); } // ���� for (int i = 0; i < scoreStr.Length; i++) { digitSprites[i].Texture = CCTextureCache.sharedTextureCache().addImage("imgs/score/" + scoreStr[i]); } if (playSound && score > 0) { SimpleAudioEngine.sharedEngine().playEffect(@"musics/sfx_point"); } }
/// <summary> /// ��Ϸ���������˵� /// </summary> private void ShowGameOverMenu() { if (gameOverLayer == null) { gameOverLayer = new CCLayer(); } // gameOver����ͼƬ CCSprite gameOverImageSprite = CCSprite.spriteWithFile("imgs/start/gameOver"); gameOverImageSprite.position = new CCPoint(AppDelegate.screenSize.width / 2, AppDelegate.screenSize.height * 4 / 5); gameOverLayer.addChild(gameOverImageSprite); // �÷�PanelͼƬ CCSprite scorePanel = CCSprite.spriteWithFile("imgs/start/scorePanel"); scorePanel.position = new CCPoint(AppDelegate.screenSize.width / 2, AppDelegate.screenSize.height * 3 / 5); gameOverLayer.addChild(scorePanel); // �÷� CCLayer currentScoreLayer = new CCLayer(); List<CCSprite> digitSpriteList = new List<CCSprite>(); currentScoreLayer.scale = 0.5f; currentScoreLayer.position = new CCPoint(AppDelegate.screenSize.width / 2 + 60, AppDelegate.screenSize.height * 3 / 5 + 15); this.addChild(currentScoreLayer); UpdateScore(digitSpriteList, currentScoreLayer, score, false); gameOverLayer.addChild(currentScoreLayer); // ��߷� using (IsolatedStorageFileStream stream = IsolatedStorageFile.GetUserStoreForApplication().OpenFile("/score.data", System.IO.FileMode.OpenOrCreate, FileAccess.ReadWrite)) { StreamReader reader = new StreamReader(stream); string res = reader.ReadToEnd(); if (!string.IsNullOrEmpty(res)) { highestScore = Convert.ToInt32(res); } if (!IsolatedStorageFile.GetUserStoreForApplication().FileExists("score.data")) { IsolatedStorageFile.GetUserStoreForApplication().CreateFile("score.data"); } } using (IsolatedStorageFileStream stream = IsolatedStorageFile.GetUserStoreForApplication().OpenFile("/score.data", System.IO.FileMode.OpenOrCreate, FileAccess.ReadWrite)) { if (score > highestScore) { highestScore = score; byte[] buffer = UTF8Encoding.UTF8.GetBytes(highestScore.ToString()); stream.Write(buffer, 0, buffer.Length); stream.Flush(); stream.Close(); stream.Dispose(); CCSprite newHighScore = CCSprite.spriteWithFile("imgs/start/new"); newHighScore.position = new CCPoint(AppDelegate.screenSize.width / 2 + 35, AppDelegate.screenSize.height * 3 / 5 - 8); gameOverLayer.addChild(newHighScore); } } CCLayer highestScoreLayer = new CCLayer(); List<CCSprite> highestScoreDigitSpriteList = new List<CCSprite>(); highestScoreLayer.scale = 0.5f; highestScoreLayer.position = new CCPoint(AppDelegate.screenSize.width / 2 + 60, AppDelegate.screenSize.height * 3 / 5 - 30); this.addChild(highestScoreLayer); UpdateScore(highestScoreDigitSpriteList, highestScoreLayer, highestScore, false); gameOverLayer.addChild(highestScoreLayer); #region ��ť // ��ʼ��ť CCSprite btnStart = CCSprite.spriteWithFile("imgs/start/btn_start"); CCSprite btn_startSelected = CCSprite.spriteWithFile("imgs/start/btn_startSelected"); CCMenuItemSprite menuItemSprite1 = CCMenuItemSprite.itemFromNormalSprite(btnStart, btn_startSelected, this, (sender) => { GameScene gameScene = new GameScene(game); // ��ת����һ������ var scene = CCTransitionFade.transitionWithDuration(0.5f, gameScene); CCDirector.sharedDirector().pushScene(scene); }); // ���а� CCSprite btnHighScore = CCSprite.spriteWithFile("imgs/start/btn_highScore"); CCSprite btnHighScoreSelected = CCSprite.spriteWithFile("imgs/start/btn_highScoreSelected"); CCMenuItemSprite menuItemSprite2 = CCMenuItemSprite.itemFromNormalSprite(btnHighScore, btnHighScoreSelected, this, (sender) => { game.Exit(); }); CCMenu menu = CCMenu.menuWithItems(menuItemSprite1, menuItemSprite2); menu.position = new CCPoint(AppDelegate.screenSize.width / 2, ground.contentSize.height + btnStart.contentSize.height / 2); //�˵�ˮƽ���� menu.alignItemsHorizontallyWithPadding(20); this.addChild(menu); #endregion this.addChild(gameOverLayer); }
/// <summary> /// ��ʼ���÷� /// </summary> private void InitScore() { scoreLayer = new CCLayer(); scoreLayer.position = new CCPoint(50, AppDelegate.screenSize.height - 50); this.addChild(scoreLayer); if (digitSprites == null) { digitSprites = new List<CCSprite>(); } UpdateScore(digitSprites, scoreLayer, score, true); }
/// <summary> /// ��� /// </summary> private void AddBarLayer() { barLayer = new CCLayer(); this.addChild(barLayer); // ��ʱ�����ϰ��� CCScheduler.sharedScheduler().scheduleSelector(AddBar, this, createBarInterval, true); }
public void OnClick(CCLayer p_Layer) { m_Speaker.OnClick(p_Layer); }
public override void onEnter() { base.onEnter(); // create a transparent color layer // in which we are going to add our rendertextures ccColor4B color = new ccColor4B(0, 0, 0, 0); CCSize size = CCDirector.sharedDirector().getWinSize(); //CCLayerColor layer = CCLayerColor.layerWithColor(color); CCLayer layer = new CCLayer(); // create the first render texture for inScene CCRenderTexture inTexture = CCRenderTexture.renderTextureWithWidthAndHeight((int)size.width, (int)size.height); if (null == inTexture) { return; } inTexture.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f); inTexture.position = new CCPoint(size.width / 2, size.height / 2); inTexture.anchorPoint = new CCPoint(0.5f, 0.5f); // render inScene to its texturebuffer inTexture.begin(); m_pInScene.visit(); inTexture.end(); // create the second render texture for outScene CCRenderTexture outTexture = CCRenderTexture.renderTextureWithWidthAndHeight((int)size.width, (int)size.height); outTexture.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f); outTexture.position = new CCPoint(size.width / 2, size.height / 2); outTexture.anchorPoint = new CCPoint(0.5f, 0.5f); // render outScene to its texturebuffer outTexture.begin(); m_pOutScene.visit(); outTexture.end(); // create blend functions ccBlendFunc blend1 = new ccBlendFunc(OGLES.GL_ONE, OGLES.GL_ONE); // inScene will lay on background and will not be used with alpha ccBlendFunc blend2 = new ccBlendFunc(OGLES.GL_SRC_ALPHA, OGLES.GL_ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha // set blendfunctions inTexture.Sprite.BlendFunc = blend1; outTexture.Sprite.BlendFunc = blend2; // add render textures to the layer layer.addChild(inTexture); layer.addChild(outTexture); // initial opacity: inTexture.Sprite.Opacity = 255; outTexture.Sprite.Opacity = 255; // create the blend action CCAction layerAction = CCSequence.actions ( CCFadeTo.actionWithDuration(m_fDuration, 0), CCCallFunc.actionWithTarget(this, (base.hideOutShowIn)), CCCallFunc.actionWithTarget(this, (base.finish)) ); //// run the blend action outTexture.Sprite.runAction(layerAction); // add the layer (which contains our two rendertextures) to the scene addChild(layer, 2, kSceneFade); }
public override void OnEnter() { base.OnEnter(); Color = CCTypes.CCBlack; RemoveChild(m_background, true); m_background = null; m_emitter = new CCParticleSystemQuad("Particles/LavaFlow"); m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); CCParticleBatchNode batch = new CCParticleBatchNode(m_emitter.Texture); batch.AddChild(m_emitter); AddChild(batch, 10); Schedule(switchRender, 2.0f); CCLayer node = new CCLayer(); AddChild(node); m_pParent1 = batch; m_pParent2 = node; }
public void AddLayer(CCLayer layer) { Debug.Assert(m_pLayers != null); m_pLayers.Add(layer); }
/// <summary> /// * lua script can not init with undetermined number of variables /// * so add these functinons to be used with lua. /// </summary> /// <param name="layer"></param> /// <returns></returns> public CCLayerMultiplex(CCLayer layer) { InitWithLayer(layer); }
public static new CCLayer Create() { var ret = new CCLayer(); return (ret); }