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


C# Cocos2D.CCPoint类代码示例

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


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

示例1: updateSize

 public void updateSize(CCPoint touchLocation)
 {
     CCSize s = CCDirector.SharedDirector.WinSize;
     CCSize newSize = new CCSize(Math.Abs(touchLocation.X - s.Width / 2) * 2, Math.Abs(touchLocation.Y - s.Height / 2) * 2);
     CCLayerColor l = (CCLayerColor)GetChildByTag(kTagLayer);
     l.ContentSize = newSize;
 }
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:7,代码来源:LayerTest1.cs

示例2: ParallaxScrollTest

        public ParallaxScrollTest()
        {
            CCSize screen = CCDirector.SharedDirector.WinSize;
            parallax = new CCParallaxScrollNode();
            CCSprite land1 = new CCSprite("Images/land_green");
            CCSprite land2 = new CCSprite("Images/land_green");
            parallax.AddInfiniteScrollXWithZ(0, new CCPoint(0.5f, 0.2f), CCPoint.Zero, new CCSprite[] { land1, land2 });

            CCSprite land3 = new CCSprite("Images/land_grey");
            CCSprite land4 = new CCSprite("Images/land_grey");
            parallax.AddInfiniteScrollXWithZ(-2, new CCPoint(0.05f, 0.2f), new CCPoint(0f, 60f), new CCSprite[] { land3, land4 });

            CCSprite clouds1 = new CCSprite("Images/clouds");
            CCSprite clouds2 = new CCSprite("Images/clouds");
            parallax.AddInfiniteScrollXWithZ(1, new CCPoint(0.1f, 0.1f), new CCPoint(0f, screen.Height - clouds1.ContentSize.Height), new CCSprite[] { clouds1, clouds2 });

            for (int i = 0; i < 10; i++)
            {
                CCSprite mountain = new CCSprite("Images/mountain_grey");
                CCPoint pos = new CCPoint(CCMacros.CCRandomBetween0And1() * land1.ContentSize.Width * 2f, (0.1f + 0.24f * CCMacros.CCRandomBetween0And1()) * screen.Height);

                float speedMountainX = 0.15f + CCMacros.CCRandomBetween0And1() * 0.1f;
                parallax.AddChild(mountain, -1, new CCPoint(speedMountainX, .015f), pos, new CCPoint(land1.ContentSize.Width * 2f, 0));

                mountain.Scale = 0.6f + CCMacros.CCRandomBetween0And1() * 0.4f;
            }

            CCSprite sky = new CCSprite("Images/sky_evening");
            sky.AnchorPoint = CCPoint.AnchorLowerLeft;
            AddChild(parallax);
            AddChild(sky, -1);
        }
开发者ID:hossainiir,项目名称:cocos2d-xna,代码行数:32,代码来源:ParallaxScrollTest.cs

示例3: Update

        public override void Update(float time)
        {
            int i, j;
            CCPoint c = m_positionInPixels;

            for (i = 0; i < (m_sGridSize.X + 1); ++i)
            {
                for (j = 0; j < (m_sGridSize.Y + 1); ++j)
                {
                    CCVertex3F v = OriginalVertex(new CCGridSize(i, j));

                    var avg = new CCPoint(i - (m_sGridSize.X / 2.0f), j - (m_sGridSize.Y / 2.0f));
                    var r = (float) Math.Sqrt((avg.X * avg.X + avg.Y * avg.Y));

                    float amp = 0.1f * m_fAmplitude * m_fAmplitudeRate;
                    float a = r * (float) Math.Cos((float) Math.PI / 2.0f + time * (float) Math.PI * m_nTwirls * 2) *
                              amp;

                    float dx = (float) Math.Sin(a) * (v.Y - c.Y) + (float) Math.Cos(a) * (v.X - c.X);
                    float dy = (float) Math.Cos(a) * (v.Y - c.Y) - (float) Math.Sin(a) * (v.X - c.X);

                    v.X = c.X + dx;
                    v.Y = c.Y + dy;

                    SetVertex(new CCGridSize(i, j), ref v);
                }
            }
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:28,代码来源:CCTwirl.cs

示例4: StackObject

        public StackObject(b2World world, 
		                    CCPoint location,
		                    string spriteFileName,
		                    bool breaksOnGround,
		                    bool breaksFromNinja,
		                    bool hasAnimatedBreakFrames,
		                    bool damagesEnemy,
		                    float density,
		                    CreationMethod createHow,
		                    int angleChange,
		                    bool makeImmovable,
		                    int points,
		                    BreakEffect simpleScoreVisualFXType)
        {
            InitWithWorld(world,
                          location,
                          spriteFileName,
                          breaksOnGround,
                          breaksFromNinja,
                          hasAnimatedBreakFrames,
                          damagesEnemy,
                          density,
                          createHow,
                          angleChange,
                          makeImmovable,
                          points,
                          simpleScoreVisualFXType);
        }
开发者ID:johnkg,项目名称:AngryNinjas,代码行数:28,代码来源:StackObject.cs

示例5: addNewSpriteWithCoords

        public 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));
            BatchNode.AddChild(sprite);

            sprite.Position = (new CCPoint(p.X, p.Y));

            CCActionInterval 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);

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

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

示例6: Transform

 public static CCPoint Transform(CCPoint point, CCAffineTransform t)
 {
     return new CCPoint(
         t.a * point.X + t.c * point.Y + t.tx,
         t.b * point.X + t.d * point.Y + t.ty
         );
 }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:CCAffineTransform.cs

示例7: DrawPoints

 public static void DrawPoints(CCPoint[] points, int numberOfPoints, float size, CCColor4B color)
 {
     for (int i = 0; i < numberOfPoints; i++)
     {
         DrawPoint(points[i], size, color);
     }
 }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:CCDrawingPrimitives.cs

示例8: GameMenu

		public GameMenu ()
		{
			var screenSize = CCDirector.SharedDirector.WinSize;
			
			voiceButtonName = "VoiceFX";
			voiceButtonNameDim = "VoiceFX";
			
			soundButtonName = "SoundFX";
			soundButtonNameDim = "SoundFX";
			
			ambientButtonName = "AmbientFX";
			ambientButtonNameDim = "AmbientFX";
			

			SoundFXMenuLocation = new CCPoint( 110, 55 );
			VoiceFXMenuLocation = new CCPoint( 230, 55 );
			AmbientFXMenuLocation = new CCPoint(355, 55 );
			

			TouchEnabled = true;
			

			IsSoundFXMenuItemActive = !GameData.SharedData.AreSoundFXMuted;

			IsVoiceFXMenuActive = !GameData.SharedData.AreVoiceFXMuted;

			IsAmbientFXMenuActive = !GameData.SharedData.AreAmbientFXMuted;

		}			
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:29,代码来源:GameMenu.cs

示例9: DrawLine

        public static void DrawLine(CCPoint origin, CCPoint destination, CCColor4B color)
        {
            var c = new Color(color.R, color.G, color.B, color.A);

            m_Batch.AddVertex(new Vector2(origin.X, origin.Y), c, PrimitiveType.LineList);
            m_Batch.AddVertex(new Vector2(destination.X, destination.Y), c, PrimitiveType.LineList);
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:CCDrawingPrimitives.cs

示例10: better

		bool enemyCantBeDamagedForShortInterval; // after damage occurs the enemy gets a moment of un-damage-abilty, which should play better ( I think)
		

		public Enemy (b2World world,
		              CCPoint location,
		              string spriteFileName,
		              bool isTheRotationFixed,
		              bool getsDamageFromGround,
		              bool doesGetDamageFromDamageEnabledStackObjects,
		              int breaksFromHowMuchContact,
		              bool hasDifferentSpritesForDamage,
		              int numberOfFramesToAnimateOnBreak,
		              float density,
		              CreationMethod createHow,
		              int points,
		              BreakEffect simpleScoreVisualFXType )
		{
			InitWithWorld( world,
			               location,
			               spriteFileName,
			               isTheRotationFixed,
			               getsDamageFromGround,
			               doesGetDamageFromDamageEnabledStackObjects,
			               breaksFromHowMuchContact,
			               hasDifferentSpritesForDamage,
			               numberOfFramesToAnimateOnBreak,
			               density,
			               createHow,
			               points,
			               simpleScoreVisualFXType );
		}
开发者ID:Karunp,项目名称:AngryNinjas,代码行数:31,代码来源:Enemy.cs

示例11: addNewSpriteWithCoords

        public void addNewSpriteWithCoords(CCPoint p)
        {
            int idx = (int)(CCMacros.CCRandomBetween0And1() * 1400.0f / 100.0f);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;

            CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(x, y, 85, 121));
            AddChild(sprite);

            sprite.Position = p;

            CCActionInterval action;
            float random = CCMacros.CCRandomBetween0And1();

            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);
            object obj = action.Reverse();
            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCActionInterval seq = (CCActionInterval)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
开发者ID:rtabbara,项目名称:cocos2d-xna,代码行数:30,代码来源:Sprite1.cs

示例12: Update

        public override void Update(float time)
        {
            if (m_pTarget != null)
            {
                float xa = 0;
                float xb = m_sConfig.ControlPoint1.X;
                float xc = m_sConfig.ControlPoint2.X;
                float xd = m_sConfig.EndPosition.X;

                float ya = 0;
                float yb = m_sConfig.ControlPoint1.Y;
                float yc = m_sConfig.ControlPoint2.Y;
                float yd = m_sConfig.EndPosition.Y;

                float x = CCSplineMath.CubicBezier(xa, xb, xc, xd, time);
                float y = CCSplineMath.CubicBezier(ya, yb, yc, yd, time);

                CCPoint currentPos = m_pTarget.Position;
                CCPoint diff = currentPos - m_previousPosition;
                m_startPosition = m_startPosition + diff;
        
                CCPoint newPos = m_startPosition + new CCPoint(x, y);
                m_pTarget.Position = newPos;

                m_previousPosition = newPos;
            }
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:27,代码来源:CCBezierBy.cs

示例13: InitWithTarget

 /// <summary>
 /// Initializes a CCMenuItem with a target/selector
 /// </summary>
 /// <param name="selector"></param>
 /// <returns></returns>
 public bool InitWithTarget(SEL_MenuHandler selector)
 {
     AnchorPoint = new CCPoint(0.5f, 0.5f);
     m_pfnSelector = selector;
     m_bIsEnabled = true;
     m_bIsSelected = false;
     return true;
 }
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:13,代码来源:CCMenuItem.cs

示例14: resetAndScoreBallForPlayer

        public void resetAndScoreBallForPlayer(int player)
        {
            m_ballStartingVelocity = new CCPoint(m_ballStartingVelocity.X * -1.1f, m_ballStartingVelocity.Y * -1.1f);
            m_ball.Velocity = m_ballStartingVelocity;
            m_ball.Position = new CCPoint(160.0f, 240.0f);

            // TODO -- scoring
        }
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:8,代码来源:PongLayer.cs

示例15: InitWithTarget

 /// <summary>
 /// Initializes a CCMenuItem with a target/selector
 /// </summary>
 /// <param name="selector"></param>
 /// <returns></returns>
 public bool InitWithTarget(Action<object> selector)
 {
     AnchorPoint = new CCPoint(0.5f, 0.5f);
     m_pfnSelector = selector;
     m_bIsEnabled = true;
     m_bIsSelected = false;
     return true;
 }
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:13,代码来源:CCMenuItem.cs


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