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


C# CCPoint类代码示例

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


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

示例1: AddedToScene

        protected override void AddedToScene()
        {
            base.AddedToScene();

            // Use the bounds to layout the positioning of our drawable assets
            var bounds = VisibleBoundsWorldspace;

            // position the label on the center of the screen
            label.Position = bounds.LowerLeft;

            //Ubicar las 6 sillas al inicio
            //TODO hallar el centro de la pantalla
            CCSize tamaño = Scene.Window.WindowSizeInPixels;
            CCPoint centro = tamaño.Center;
            double cx = centro.X;
            double cy = centro.Y;
            double radio = 200;

            for (int i = 0; i < sillas.Count; i++)
            {
                double xpos = cx + radio * Math.Sin(2 * Math.PI / 6 * i);
                double ypos = cy + radio * Math.Cos(2 * Math.PI / 6 * i);
                CCPoint position = new CCPoint((float)xpos, (float)ypos);
                sillas[i].Position = position;
                sillas[i].Rotation = (float)(180 + 360 / 6 * i);
            }

            // Register for touch events
            var touchListener = new CCEventListenerTouchAllAtOnce();
            touchListener.OnTouchesEnded = OnTouchesEnded;
            AddEventListener(touchListener, this);
        }
开发者ID:sanslash332,项目名称:codename-the-great-and-powerful-phone-party,代码行数:32,代码来源:IntroLayer.cs

示例2: CCRipple3D

 public CCRipple3D (float duration, CCGridSize gridSize, CCPoint position, float radius, int waves, float amplitude)
     : base (duration, gridSize, amplitude)
 {
     Position = position;
     Radius = radius;
     Waves = waves;
 }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:7,代码来源:CCRipple3D.cs

示例3: ProjectVelocityOnSurface

        protected void ProjectVelocityOnSurface(CCPoint reposition)
        {
            if (reposition.X != 0 || reposition.Y != 0)
            {
                var repositionNormalized = reposition;

                //vector归一化
                repositionNormalized.Normalize ();

                CCPoint velocity = new CCPoint (VelocityX, VelocityY);

                //计算velocity和repositionNormalized的点积,得到瓦片位移向量作用后的位置
                var dot = CCPoint.Dot (velocity, repositionNormalized);

                // falling into the collision, rather than out of
                //如果dot小于0,则entity掉入瓦片中(掉入被撞击的物体中)
                //掉入是正常现象
                //之后把entity的速度更改下
                //如果是在地面,速度会被改为0
                //不太懂这个算法
                if (dot < 0)
                {
                    velocity -= repositionNormalized * dot;

                    VelocityX = velocity.X;
                    VelocityY = velocity.Y;

                }
            }
        }
开发者ID:coroner4817,项目名称:CoinTime,代码行数:30,代码来源:PhysicsEntity.cs

示例4: CCLens3D

 public CCLens3D (float duration, CCGridSize gridSize, CCPoint position, float radius) : base (duration, gridSize)
 {
     Position = position;
     Radius = radius;
     LensScale = 0.7f;
     Concave = false;
 }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:7,代码来源:CCLens3D.cs

示例5: UpdateBallTransform

        public void UpdateBallTransform()
        {
            if (PhysicsBody != null)
            {
                b2Vec2 pos = PhysicsBody.Position;

                float x = pos.x * ptmRatio;
                float y = pos.y * ptmRatio;

                if (IgnoreAnchorPointForPosition) 
                {
                    x += AnchorPointInPoints.X;
                    y += AnchorPointInPoints.Y;
                }

                // Make matrix
                float radians = PhysicsBody.Angle;
                var c = (float)Math.Cos (radians);
                var s = (float)Math.Sin (radians);

                if (!AnchorPointInPoints.Equals (CCPoint.Zero)) 
                {
                    x += c * -AnchorPointInPoints.X + -s * -AnchorPointInPoints.Y;
                    y += s * -AnchorPointInPoints.X + c * -AnchorPointInPoints.Y;
                }

                Position = new CCPoint(x, y);
            }
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:29,代码来源:CCPhysicsSprite.cs

示例6: actionWithDuration

        /** creates the action */
        public static CCMoveTo actionWithDuration(float duration, CCPoint position)
        {
            CCMoveTo moveTo = new CCMoveTo();
            moveTo.initWithDuration(duration, position);

            return moveTo;
        }
开发者ID:liwq-net,项目名称:liwq718,代码行数:8,代码来源:CCMoveTo.cs

示例7: 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

示例8: DistanceTo

		public float DistanceTo(ref CCPoint vector, out Segment connectingSegment)
		{
			float segmentLength = (float)this.GetLength();

			CCPoint normalizedLine = new CCPoint(
				(float)(Point2.X - Point1.X) / segmentLength,
				(float)(Point2.Y - Point1.Y) / segmentLength);

			CCPoint pointVector = new CCPoint((float)(vector.X - Point1.X), (float)(vector.Y - Point1.Y));

			float length = CCPoint.Dot(pointVector, normalizedLine);
			connectingSegment = new Segment ();
			if (length < 0)
			{
				connectingSegment.Point1 = vector;
				connectingSegment.Point2 = Point1;

				return (float) connectingSegment.GetLength();
			}
			else if (length > segmentLength)
			{
				connectingSegment.Point1 = vector;
				connectingSegment.Point2 = Point2;

				return (float) connectingSegment.GetLength();
			}
			else
			{
				connectingSegment.Point1 = vector;
				connectingSegment.Point2 = new CCPoint(Point1.X + length * normalizedLine.X,
					Point1.Y + length * normalizedLine.Y);

				return (float)connectingSegment.GetLength();
			}
		}
开发者ID:CodeSensei,项目名称:mobile-samples,代码行数:35,代码来源:Segment.cs

示例9: JumpPad

        public JumpPad(b2Vec2 JumpImpuls, CCPoint Position, b2World gameWorld)
        {
            this.Texture = new CCTexture2D ("jumppad");
            this.Scale = SpriteScale;
            this.Position = Position;
            this.IsAntialiased = false;

            jumpImpuls = JumpImpuls;
            totalJumps = 0;

            //box2d
            b2BodyDef jumpPadDef = new b2BodyDef ();
            jumpPadDef.type = b2BodyType.b2_kinematicBody;
            jumpPadDef.position = new b2Vec2 ((Position.X + this.ScaledContentSize.Width/2)/PhysicsHandler.pixelPerMeter, (Position.Y + this.ScaledContentSize.Height/4) / PhysicsHandler.pixelPerMeter);
            JumpPadBody = gameWorld.CreateBody (jumpPadDef);

            b2PolygonShape jumpPadShape = new b2PolygonShape ();
            jumpPadShape.SetAsBox ((float)this.ScaledContentSize.Width / PhysicsHandler.pixelPerMeter / 2, (float)this.ScaledContentSize.Height / PhysicsHandler.pixelPerMeter / 4);// /4 weil die hitbox nur die hälfte der textur ist

            b2FixtureDef jumpPadFixture = new b2FixtureDef ();
            jumpPadFixture.shape = jumpPadShape;
            jumpPadFixture.density = 0.0f; //Dichte
            jumpPadFixture.restitution = 0f; //Rückprall
            jumpPadFixture.friction = 0f;
            jumpPadFixture.userData = WorldFixtureData.jumppad;
            JumpPadBody.CreateFixture (jumpPadFixture);
            //
        }
开发者ID:Nuckal777,项目名称:mapKnight,代码行数:28,代码来源:JumpPad.cs

示例10: RubeBasicLayer

        public RubeBasicLayer(string jsonfile)
        {
            AnchorPoint = new CCPoint(0, 0);

            HasWheel = true;

            JSON_FILE = jsonfile;

            TouchPanel.EnabledGestures = GestureType.Pinch | GestureType.PinchComplete;

            var touchListener = new CCEventListenerTouchAllAtOnce();
            touchListener.OnTouchesBegan = OnTouchesBegan;
            touchListener.OnTouchesMoved = OnTouchesMoved;
            touchListener.OnTouchesEnded = OnTouchesEnded;
            touchListener.OnTouchesCancelled = OnTouchesCancelled;
            AddEventListener(touchListener, this);

            var mouseListener = new CCEventListenerMouse();
            mouseListener.OnMouseScroll = OnMouseScroll;
            AddEventListener(mouseListener, this);

            // set the starting scale and offset values from the subclass
            Position = InitialWorldOffset();
            Scale = InitialWorldScale();

            // load the world from RUBE .json file (this will also call afterLoadProcessing)
            LoadWorld();
        }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:28,代码来源:RubeBasicLayer.cs

示例11: 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:headinthebox,项目名称:cocos-sharp-samples,代码行数:31,代码来源:Enemy.cs

示例12: DrawSolidCircle

        public override void DrawSolidCircle(Box2D.Common.b2Vec2 center, float radius, Box2D.Common.b2Vec2 axis, Box2D.Common.b2Color color)
        {
            CCPoint centerToPoint = new CCPoint (center.x * 50f, center.y * 50f);
            //CCColor4B Color = new CCColor4B (color.r, color.g, color.b, 255);

            DrawNode.DrawCircle (centerToPoint, radius, CollusionColor);
        }
开发者ID:Nuckal777,项目名称:mapKnight,代码行数:7,代码来源:DebugDraw.cs

示例13: GameMenu

        public GameMenu()
        {
            var screenSize = Director.WindowSizeInPixels;

            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:KerwinMa,项目名称:CocosSharp,代码行数:29,代码来源:GameMenu.cs

示例14: Update

        public override void Update(float time)
        {
            if (m_pTarget != null)
            {
                // Is % equal to fmodf()???
                float frac = (time * m_nJumps) % 1f;
                float y = m_height * 4f * frac * (1f - frac);
                y += m_delta.Y * time;
                float x = m_delta.X * time;
#if CC_ENABLE_STACKABLE_ACTIONS
                CCPoint currentPos = m_pTarget.Position;

                CCPoint diff = currentPos - m_previousPos;
                m_startPosition = diff + m_startPosition;

                CCPoint newPos = m_startPosition + new CCPoint(x,y);
                m_pTarget.Position = newPos;

                m_previousPos = newPos;
#else
                m_pTarget.Position = m_startPosition + new CCPoint(x, y);
#endif
                // !CC_ENABLE_STACKABLE_ACTIONS
            }
        }
开发者ID:rtabbara,项目名称:cocos2d-xna,代码行数:25,代码来源:CCJumpBy.cs

示例15: AddNewSpriteWithCoords

        void AddNewSpriteWithCoords(CCPoint p)
        {
            CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)this[(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;
            var random = (float)CCRandom.NextDouble();

            if (random < 0.20)
                action = scaleBy;
            else if (random < 0.40)
                action = rotateBy;
            else if (random < 0.60)
                action = blink;
            else if (random < 0.8)
                action = tintBy;
            else
                action = fadeOut;

            sprite.RepeatForever(action, action.Reverse());

        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:31,代码来源:SpriteBatchNode1.cs


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