当前位置: 首页>>代码示例>>C#>>正文


C# CocosSharp.CCSprite类代码示例

本文整理汇总了C#中CocosSharp.CCSprite的典型用法代码示例。如果您正苦于以下问题:C# CCSprite类的具体用法?C# CCSprite怎么用?C# CCSprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CCSprite类属于CocosSharp命名空间,在下文中一共展示了CCSprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IntroLayer

        public IntroLayer()
            : base(CCColor4B.Gray)
        {
            titleLabel = new CCLabel("CocosJuce", "fonts/Roboto-Light-72.fnt");
            frequencyLabel = new CCLabel("", "fonts/Roboto-Light-72.fnt");

            onOffSwitchSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
            onOffSwitchSpriteFrameCache.AddSpriteFrames("images/onoffswitch.plist");

            switchOnSprite = new CCSprite("switch_on.png");
            switchOffSprite = new CCSprite("switch_off.png");
            onOffSwitch = new CCMenuItemToggle(SwitchToggle, new CCMenuItem[]
                                                         {
                                                             new CCMenuItemImage(switchOffSprite) { },
                                                             new CCMenuItemImage(switchOnSprite) { },
                                                         });

            menu = new CCMenu(onOffSwitch);

            freqKnobSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
            freqKnobSpriteFrameCache.AddSpriteFrames("images/frequencyknob.plist");

            frequencyKnob = new CCSprite("frequencyknob00.png");

            AddChild(titleLabel);
            AddChild(menu);
            AddChild(frequencyLabel);
            AddChild(frequencyKnob);
        }
开发者ID:altalogix,项目名称:CocosJuce,代码行数:29,代码来源:IntroLayer.cs

示例2: StartScene

        public StartScene(CCWindow mainWindow)
            : base(mainWindow)
        {
            mainLayer = new CCLayer ();
            AddChild (mainLayer);

            PlayButton = new CCSprite ("logo");

            NameLabel = new CCLabel ("Map Knight - Alpha", "arial", 22);
            CreatorLabel = new CCLabel ("Created by tipfom and Exo", "arial", 22);
            VersionLabel = new CCLabel ("Version unspecified", "arial", 22);
            InfoLabel = new CCLabel ("Click to play", "arial", 22);

            PlayButton.ScaleX = mainWindow.WindowSizeInPixels.Width / PlayButton.ContentSize.Width;
            PlayButton.ScaleY = mainWindow.WindowSizeInPixels.Height / PlayButton.ContentSize.Height;
            PlayButton.Position = new CCPoint (PlayButton.ScaledContentSize.Width / 2, PlayButton.ScaledContentSize.Height / 2);

            NameLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, mainWindow.WindowSizeInPixels.Height / 2 - NameLabel.ContentSize.Height);
            CreatorLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, NameLabel.PositionY - CreatorLabel.ContentSize.Height - 30);
            VersionLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, CreatorLabel.PositionY - VersionLabel.ContentSize.Height - 30);
            InfoLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, VersionLabel.PositionY - InfoLabel.ContentSize.Height - 30);

            mainLayer.AddChild (PlayButton);
            mainLayer.AddChild (NameLabel);
            mainLayer.AddChild (CreatorLabel);
            mainLayer.AddChild (VersionLabel);
            mainLayer.AddChild (InfoLabel);

            touchListener = new CCEventListenerTouchAllAtOnce ();
            touchListener.OnTouchesEnded = HandleTouchesEnded;
            AddEventListener (touchListener, this);
        }
开发者ID:Nuckal777,项目名称:mapKnight,代码行数:32,代码来源:StartScene.cs

示例3: PopUpLayer

        public PopUpLayer(CCSprite background, CCLabel title)
        {
            mBackgroundImage = background;
            mTitle = title;

            CreateLayer ();
        }
开发者ID:coroner4817,项目名称:MyBouncingGame,代码行数:7,代码来源:PopUpLayer.cs

示例4: SpriteWithColor

        public SpriteWithColor(CCColor4B bgColor, CCSize textureSizeInPixels) : base ()
        {
            // 1: Create new CCRenderTexture
            CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);

            // 2: Call CCRenderTexture:begin
            rt.BeginWithClear(bgColor);

            // 3: Draw into the texture
            // You'll add this later
            GenerateGradient(textureSizeInPixels);


            var noise = new CCSprite("images/Noise.png");
            noise.AnchorPoint = CCPoint.AnchorLowerLeft;
            noise.Position = CCPoint.Zero;
            noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
            noise.Texture.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.LinearWrap;

            // To get the linear wrap to work correctly we have to set the TextureRectInPixels as well as ContentSize
            noise.TextureRectInPixels = new CCRect(0, 0, textureSizeInPixels.Width, textureSizeInPixels.Height);
            noise.ContentSize = noise.TextureRectInPixels.Size;
            noise.Visit();

            // 4: Call CCRenderTexture:end
            rt.End();

            this.Texture = rt.Texture;

        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:30,代码来源:SpriteWithColor.cs

示例5: SpriteOffsetAnchorRotation

        public SpriteOffsetAnchorRotation()
        {
            sprites = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

            // Create actions

            CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;
            cache.AddSpriteFrames("animations/grossini.plist");
            cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray");
            var animFrames = new List<CCSpriteFrame>();
            string tmp = "";
            for (int j = 0; j < 14; j++)
            {
                tmp = string.Format("grossini_dance_{0:00}.png", j + 1);
                CCSpriteFrame frame = cache[tmp];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.3f);

            for (int i = 0; i < numOfSprites; i++)
            {
                // Animation using Sprite batch
                sprites[i] = new CCSprite("grossini_dance_01.png");
                AddChild(sprites[i], 0);

                pointSprites[i] = new CCSprite("Images/r1");
                AddChild(pointSprites[i], 1);
            }
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:31,代码来源:SpriteOffsetAnchorRotation.cs

示例6: GameLayer

		public GameLayer ()
        {
            var touchListener = new CCEventListenerTouchAllAtOnce();
            touchListener.OnTouchesEnded = OnTouchesEnded;

            EventDispatcher.AddEventListener(touchListener, this);
            Color = new CCColor3B (CCColor4B.White);
			Opacity = 255;

			visibleBananas = new List<CCSprite> ();
			hitBananas = new List<CCSprite> ();
	
			monkey = new CCSprite ("Monkey");
			monkey.Position = CCDirector.SharedDirector.WinSize.Center;
			AddChild (monkey);

			Schedule ((t) => {
				visibleBananas.Add (AddBanana ());
				dt += t;
				if(ShouldEndGame ()){
					var gameOverScene = GameOverLayer.SceneWithScore(hitBananas.Count);
					CCTransitionFadeDown transitionToGameOver = new CCTransitionFadeDown(1.0f, gameOverScene);
					CCDirector.SharedDirector.ReplaceScene (transitionToGameOver);
				}
			}, 1.0f);

			Schedule ((t) => {
				CheckCollision ();
			});
		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:30,代码来源:GameLayer.cs

示例7: SpriteChildrenVisibilityIssue665

        public SpriteChildrenVisibilityIssue665()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");


            aParent = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(aParent, 0);

            sprite1 = new CCSprite("grossini_dance_01.png");
            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite3 = new CCSprite("grossini_dance_03.png");

            // test issue #665
            sprite1.Visible = false;

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, 2);

            aParent2 = new CCNode();
            AddChild(aParent2, 0);

            sprite4 = new CCSprite("grossini_dance_01.png");
            sprite5 = new CCSprite("grossini_dance_02.png");
            sprite6 = new CCSprite("grossini_dance_03.png");

            // test issue #665
            sprite4.Visible = false;

            aParent2.AddChild(sprite4);
            sprite4.AddChild(sprite5, -2);
            sprite4.AddChild(sprite6, 2);
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:33,代码来源:SpriteChildrenVisibilityIssue665.cs

示例8: GameLayer

        public GameLayer()
            : base(CCColor4B.Blue, CCColor4B.AliceBlue)
        {
            // Set the layer gradient direction
            this.Vector = new CCPoint(0.5f, 0.5f);

            // Create and add sprites
            monkeySprite1 = new CCSprite("monkey");
            AddChild(monkeySprite1, 1);

            monkeySprite2 = new CCSprite("monkey");
            AddChild(monkeySprite2, 1);

            // Define actions
            var moveUp = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f));
            var moveDown = moveUp.Reverse();

            // A CCSequence action runs the list of actions in ... sequence!
            CCSequence moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown));

            repeatedAction = new CCRepeatForever(moveSeq);

            // A CCSpawn action runs the list of actions concurrently
            dreamAction = new CCSpawn(new CCFadeIn(5.0f), new CCWaves(5.0f, new CCGridSize(10, 20), 4, 4));

            // Schedule for method to be called every 0.1s
            Schedule(UpdateLayerGradient, 0.1f);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:28,代码来源:GameLayer.cs

示例9: TextLayer

		public TextLayer() : base()
		{

            Camera = AppDelegate.SharedCamera;
            contentLayer = new CCLayer();
            CCCamera contentCamera = new CCCamera(Camera.OrthographicViewSizeWorldspace, Camera.CenterInWorldspace, Camera.TargetInWorldspace);
            contentLayer.Camera = contentCamera;

            var bg = new CCSprite(TestResource.s_back3);
            BaseNode = bg;
            contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);
            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();
            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);
            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2 = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();
            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
            contentLayer.AddChild(colorBackground, -1);
		}
开发者ID:netonjm,项目名称:CocosSharp,代码行数:30,代码来源:TextLayer.cs

示例10: Test6

        public Test6()
        {
            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1);

            CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2);
            CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, 160));
            sp2.Position = (new CCPoint(380, 160));

            CCFiniteTimeAction rot = new CCRotateBy (2, 360);
            var rot_back = rot.Reverse();
			var forever1 = new CCRepeatForever (rot, rot_back);

            AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
            sp1.AddChild(sp11);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
            sp2.AddChild(sp21);

            sp1.RunAction(forever1);
            sp11.RunAction(forever1);
			sp2.RunAction(forever1);
            sp21.RunAction(forever1);

            Schedule(addAndRemove, 2.0f);
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:27,代码来源:Test6.cs

示例11: Test5

        public Test5()
        {
            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            sp2 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, 160));
            sp2.Position = (new CCPoint(380, 160));

			var rot = new CCRotateBy (2, 360);
            var rot_back = rot.Reverse();

			var forever = new CCRepeatForever (rot, rot_back) { Tag = 101 };

			// Since Actions are immutable to set the tag differently we need to 
			// create a new action.  Notice that the same actions can be used in
			// this case instead of copying them as well.
			forever2 = new CCRepeatForever (rot, rot_back) { Tag = 102 };
            
            AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);

            RemoveChild(sp2, true);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);

            // Sprite 1 should run and run
            // Sprite 2 should stop
            sp1.RunAction(forever);
            sp2.RunAction(forever2);

            // Experiment with removing sp2 and re-adding it after cleanup to reproduce an error in child management
			//ScheduleOnce(Stage2OfTest, 2.0f);
			Schedule(addAndRemove, 2.0f);
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:33,代码来源:Test5.cs

示例12: TextLayer

        public TextLayer() : base()
        {

            Color = new CCColor3B(32, 128, 32);
            Opacity = 255;

            BaseNode = new CCNodeGrid();
            var effect = CurrentAction;
            BaseNode.RunAction(effect);
            AddChild(BaseNode, 0, EffectTestScene.kTagBackground);

            var bg = new CCSprite(TestResource.s_back3);
            BaseNode.AddChild(bg, 0);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);
            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();
            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);
            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2 = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();
            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

        }
开发者ID:AnimaRobotics,项目名称:CocosSharp,代码行数:30,代码来源:TextLayer.cs

示例13: SpriteZVertex

        public SpriteZVertex()
        {
            //
            // This test tests z-order
            // If you are going to use it is better to use a 3D projection
            //
            // WARNING:
            // The developer is resposible for ordering it's sprites according to it's Z if the sprite has
            // transparent parts.
            //

            dir = 1;
            time = 0;
            sprites = new CCSprite[numOfSprites];

            node = new CCNode();
            AddChild(node, 0);

            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:32,代码来源:SpriteZVertex.cs

示例14: TextLayer

		public TextLayer() : base()
		{

            contentLayer = new CCLayer();
            CCCamera contentCamera = Camera;
            contentLayer.Camera = contentCamera;

            var bg = new CCSprite(TestResource.s_back3);
            BaseNode = bg;
            contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);
            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();
            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);
            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2 = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();
            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
            contentLayer.AddChild(colorBackground, -1);
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:29,代码来源:TextLayer.cs

示例15: AddNewSpriteWithCoords

        void AddNewSpriteWithCoords(CCPoint p)
        {
            CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

            int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;


            CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121));
            sprite.Position = (new CCPoint(p.X, p.Y));
            BatchNode.AddChild(sprite);


            CCFiniteTimeAction action = null;
            float random = (float)CCRandom.NextDouble();

            if (random < 0.20)
                action = new CCScaleBy(3, 2);
            else if (random < 0.40)
                action = new CCRotateBy (3, 360);
            else if (random < 0.60)
                action = new CCBlink (1, 3);
            else if (random < 0.8)
                action = new CCTintBy (2, 0, -255, -255);
            else
                action = new CCFadeOut  (2);

            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
            CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:33,代码来源:SpriteBatchNode1.cs


注:本文中的CocosSharp.CCSprite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。