// CCLayer
 public override bool ccTouchBegan(CCTouch pTouch, CCEvent pEvent)
 {
     Debug.WriteLine("++++++++++++++++++++++++++++++++++++++++++++");
     m_beginPos = pTouch.locationInView(pTouch.view());
     m_beginPos = CCDirector.sharedDirector().convertToGL(m_beginPos);
     return true;
 }
Example #2
0
 public void SetTouchInfo(int id, float x, float y)
 {
     m_nId = id;
     m_prevPoint = m_point;
     m_point.X = x;
     m_point.Y = y;
 }
 public LayerLevels()
 {
     //�ؿ�ѡ���
     CCPoint offset = new CCPoint(170, 180);
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 3; j++)
         {
             //�ؿ��İ�ť
             CCMenuItemSprite level = CCMenuItemSprite.itemFromNormalSprite(
                 CCSprite.spriteWithSpriteFrameName("btn_level1.png"),
                 CCSprite.spriteWithSpriteFrameName("btn_level2.png"),
                 this, click_level);
             CCMenu menu = CCMenu.menuWithItems(level);
             //λ����������ϵ�UI����
             menu.position = CCDirector.sharedDirector().convertToUI(new CCPoint(offset.x + 160 * i, offset.y + 85 * j));
             this.addChild(menu);
             //����һ��MenuItem�������ı�����
             CCMenuItem menuitem = new CCMenuItem();
             //ָ��Arial��������������֤fonts����Arial.spritefont
             var text = CCLabelTTF.labelWithString((j * 4 + i + 1).ToString(), "Arial", 12);
             //����ɫָ��Ϊ��ɫ
             text.Color = new ccColor3B();
             menuitem.addChild(text);
             menu.addChild(menuitem);
         }
     }
 }
        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);
        }
        public override void ccTouchesMoved(List<CCTouch> pTouches, CCEvent pEvent)
        {
            foreach (var it in pTouches)
            {
                CCTouch touch = it;

                CCPoint touchLocation = touch.locationInView(touch.view());
                touchLocation = CCDirector.sharedDirector().convertToGL(touchLocation);
                float nMoveY = touchLocation.y - m_tBeginPos.y;

                CCPoint curPos = m_pItmeMenu.position;
                CCPoint nextPos = new CCPoint(curPos.x, curPos.y + nMoveY);
                CCSize winSize = CCDirector.sharedDirector().getWinSize();
                if (nextPos.y < 0.0f)
                {
                    m_pItmeMenu.position = new CCPoint(0, 0);
                    return;
                }

                if (nextPos.y > ((BugsTestScene.MAX_COUNT + 1) * BugsTestScene.LINE_SPACE - winSize.height))
                {
                    m_pItmeMenu.position = new CCPoint(0, ((BugsTestScene.MAX_COUNT + 1) * BugsTestScene.LINE_SPACE - winSize.height));
                    return;
                }

                m_pItmeMenu.position = nextPos;
                m_tBeginPos = touchLocation;
                BugsTestScene.s_tCurPos = nextPos;
            }
        }
 public void Run(CCPoint p_Point)
 {
     WordListLayer start = new WordListLayer();
     start.position = p_Point;
     addChild(start);
     CCDirector.sharedDirector().replaceScene(this);
 }
        public void addNewSpriteWithCoords(CCPoint p)
        {
            CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)getChildByTag((int)kTags.kTagSpriteBatchNode);

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


            CCSprite sprite = CCSprite.spriteWithTexture(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)rand.NextDouble();

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

            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCActionInterval seq = (CCActionInterval)(CCSequence.actions(action, action_back));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
        }
Example #8
0
        public void addNewSpriteWithCoords(CCPoint p)
        {
            int idx = (int)(ccMacros.CCRANDOM_0_1() * 1400.0f / 100.0f);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;

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

            sprite.position = p;

            CCActionInterval action;
            float random = ccMacros.CCRANDOM_0_1();

            if (random < 0.20)
                action = CCScaleBy.actionWithDuration(3, 2);
            else if (random < 0.40)
                action = CCRotateBy.actionWithDuration(3, 360);
            else if (random < 0.60)
                action = CCBlink.actionWithDuration(1, 3);
            else if (random < 0.8)
                action = CCTintBy.actionWithDuration(2, 0, -255, -255);
            else
                action = CCFadeOut.actionWithDuration(2);
            object obj = action.reverse();
            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCActionInterval seq = (CCActionInterval)(CCSequence.actions(action, action_back));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
        }
 public static CCPointObject pointWithCCPoint(CCPoint ratio, CCPoint offset)
 {
     CCPointObject pRet = new CCPointObject();
     pRet.initWithCCPoint(ratio, offset);
     //pRet->autorelease();
     return pRet;
 }
 public static CCPoint CCPointApplyAffineTransform(CCPoint point, CCAffineTransform t)
 {
     CCPoint p = new CCPoint();
     p.x = (float)((double)t.a * point.x + (double)t.c * point.y + t.tx);
     p.y = (float)((double)t.b * point.x + (double)t.d * point.y + t.ty); 
     return p;
 }
 public bool initWithCCPoint(CCPoint ratio, CCPoint offset)
 {
     m_tRatio = ratio;
     m_tOffset = offset;
     m_pChild = null;
     return true;
 }
        public void addNewSprite()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCPoint p = new CCPoint((float)(Random.NextDouble() * s.Width), (float)(Random.NextDouble() * s.Height));

            CCSpriteBatchNode batch = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

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

            CCSprite sprite = new CCSprite(batch.Texture, new CCRect(x, y, 85, 121));
            batch.AddChild(sprite);

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

            CCActionInterval action;
            float random = (float)Random.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)(CCSequence.FromActions(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
Example #13
0
        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 );
        }
Example #14
0
 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;
 }
Example #15
0
        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)(CCSequence.FromActions(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
Example #16
0
        private void InitWithWorld( b2World world, CCPoint location, string spriteFileName)
        {
            this.theWorld = world;
            this.initialLocation = location;
            this.spriteImageName = spriteFileName;

            CreateGround();
        }
Example #17
0
        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
        }
Example #18
0
 /// <summary>
 /// Initializes a CCMenuItem with a target/selector
 /// </summary>
 /// <param name="rec"></param>
 /// <param name="selector"></param>
 /// <returns></returns>
 public bool initWithTarget(SelectorProtocol rec, SEL_MenuHandler selector)
 {
     anchorPoint = new CCPoint(0.5f, 0.5f);
     m_pListener = rec;
     m_pfnSelector = selector;
     m_bIsEnabled = true;
     m_bIsSelected = false;
     return true;
 }
 public override void ccTouchesBegan(List<CCTouch> pTouches, CCEvent pEvent)
 {
     foreach (var it in pTouches)
     {
         CCTouch touch = it;
         m_tBeginPos = touch.locationInView(touch.view());
         m_tBeginPos = CCDirector.sharedDirector().convertToGL(m_tBeginPos);
     }
 }
        public override float testFunc(ccGridSize pos, float time)
        {
            CCPoint n = new CCPoint((float)(m_sGridSize.x * time), (float)(m_sGridSize.y * time));
            if (n.y == 0.0f)
            {
                return 1.0f;
            }

            return (float)Math.Pow(pos.y / n.y, 6);
        }
Example #21
0
        protected bool IsTouchNode(CCNode p_Node, List<CCTouch> touches)
        {
            CCRect rect = p_Node.boundingBox();
               CCSize size = CCDirector.sharedDirector().getWinSize();

              // rect.size = p_Node.contentSize;
               CCPoint touch =new CCPoint( touches[0].locationInView(touches[0].view()).x, touches[0].locationInView(touches[0].view()).y);
               touch.y = size.height - touch.y;
            return CCRect.CCRectContainsPoint(rect, touch);
        }
 public CCTMXLayerInfo()
 {
     m_sName = "";
     m_pTiles = null;
     m_bOwnTiles = true;
     m_uMinGID = 100000;
     m_uMaxGID = 0;
     m_tOffset = new CCPoint(0, 0);
     m_pProperties =new Dictionary<string,string>(); ;
 }
        public virtual float testFunc(ccGridSize pos, float time)
        {
            CCPoint n = new CCPoint((float)(m_sGridSize.x * (1.0f - time)), (float)(m_sGridSize.y * (1.0f - time)));
            if (pos.y == 0)
            {
                return 1.0f;
            }

            return (float)Math.Pow(n.y / pos.y, 6);
        }
        public virtual float testFunc(ccGridSize pos, float time)
        {
            CCPoint n = new CCPoint((float)(m_sGridSize.x * time), (float)(m_sGridSize.y * time));
            if ((n.x + n.y) == 0.0f)
            {
                return 1.0f;
            }

            return (float)Math.Pow((pos.x + pos.y) / (n.x + n.y), 6);
        }
Example #25
0
        public override float TestFunc(CCGridSize pos, float time)
        {
            var n = new CCPoint((m_sGridSize.X * (1.0f - time)), (m_sGridSize.Y * (1.0f - time)));
            if ((pos.X + pos.Y) == 0)
            {
                return 1.0f;
            }

            return (float) Math.Pow((n.X + n.Y) / (pos.X + pos.Y), 6);
        }
        /// <summary>
        /// Creates a full-screen CCLayer with a gradient between start and end in the direction of v. 
        /// </summary>
        public static CCLayerGradient layerWithColor(ccColor4B start, ccColor4B end, CCPoint v)
        {
            CCLayerGradient pLayer = new CCLayerGradient();
            if (pLayer.initWithColor(start, end, v))
            {
                return pLayer;
            }

            return null;
        }
Example #27
0
 public void setPosition(CCPoint pos)
 {
     if (!CCPoint.CCPointEqualToPoint(pos, m_position))
     {
         m_position = pos;
         m_positionInPixels.x = pos.x * CCDirector.sharedDirector().ContentScaleFactor;
         m_positionInPixels.y = pos.y * CCDirector.sharedDirector().ContentScaleFactor;
         m_bDirty = true;
     }
 }
        public override float testFunc(ccGridSize pos, float time)
        {
            CCPoint n = new CCPoint((float)(m_sGridSize.x * (1.0f - time)), (float)(m_sGridSize.y * (1.0f - time)));
            if ((pos.x + pos.y) == 0)
            {
                return 1.0f;
            }

            return (float)Math.Pow((n.x + n.y) / (pos.x + pos.y), 6);
        }
Example #29
0
        public static CCPlace actionWithPosition(CCPoint pos) 
        {
	        CCPlace pRet = new CCPlace();

	        if (pRet != null && pRet.initWithPosition(pos)) 
            {
		        return pRet;
	        }

	        return null;
        }
Example #30
0
 /** replaces an existing controlPoint at index */
 public void replaceControlPoint(CCPoint controlPoint, int index)
 {
     // should create a new object of CCPoint
     // because developer always use this function like this
     // replaceControlPoint(ccp(x, y))
     // passing controlPoint is a temple object
     // and CCArray::insertObject() will retain the passing object, so it 
     // should be an object created in heap
     CCPoint temp = new CCPoint(controlPoint);
     m_pControlPoints[index] = temp;
 }
Example #31
0
        public CCPoint Add(CCPoint pt)
        {
            CCPoint cCPoint = new CCPoint(this.x + pt.x, this.y + pt.y);

            return(cCPoint);
        }
 public override void startWithTarget(CCNode pTarget)
 {
     base.startWithTarget(pTarget);
     this.m_startPosition = pTarget.position;
 }
Example #33
0
        public override bool initWithTotalParticles(uint numberOfParticles)
        {
            if (base.initWithTotalParticles(numberOfParticles))
            {
                // duration
                Duration = (float)eParticleShowingProperty.kCCParticleDurationInfinity;

                EmitterMode = (int)eParticleMode.kCCParticleModeGravity;

                // Gravity Mode: gravity
                modeA.gravity = new CCPoint(10, -10);

                // Gravity Mode: radial
                modeA.radialAccel    = 0;
                modeA.radialAccelVar = 1;

                // Gravity Mode: tagential
                modeA.tangentialAccel    = 0;
                modeA.tangentialAccelVar = 1;

                // Gravity Mode: speed of particles
                modeA.speed    = 130;
                modeA.speedVar = 30;

                // angle
                Angle    = -90;
                AngleVar = 5;


                // emitter position
                CCSize winSize = CCDirector.sharedDirector().getWinSize();
                this.position = new CCPoint(winSize.width / 2, winSize.height);
                PosVar        = new CCPoint(winSize.width / 2, 0);

                // life of particles
                Life    = 4.5f;
                LifeVar = 0;

                // size, in pixels
                StartSize    = 4.0f;
                StartSizeVar = 2.0f;
                EndSize      = (float)eParticleShowingProperty.kCCParticleStartSizeEqualToEndSize;

                // emits per second
                EmissionRate = 20;

                // color of particles
                StartColor.r    = 0.7f;
                StartColor.g    = 0.8f;
                StartColor.b    = 1.0f;
                StartColor.a    = 1.0f;
                StartColorVar.r = 0.0f;
                StartColorVar.g = 0.0f;
                StartColorVar.b = 0.0f;
                StartColorVar.a = 0.0f;
                EndColor.r      = 0.7f;
                EndColor.g      = 0.8f;
                EndColor.b      = 1.0f;
                EndColor.a      = 0.5f;
                EndColorVar.r   = 0.0f;
                EndColorVar.g   = 0.0f;
                EndColorVar.b   = 0.0f;
                EndColorVar.a   = 0.0f;

                // additive
                this.IsBlendAdditive = false;
                return(true);
            }
            return(false);
        }
Example #34
0
 /// <summary>
 /// set center position
 /// </summary>
 public void setPosition(CCPoint position)
 {
     m_position           = position;
     m_positionInPixels.x = position.x * CCDirector.sharedDirector().ContentScaleFactor;
     m_positionInPixels.y = position.y * CCDirector.sharedDirector().ContentScaleFactor;
 }
Example #35
0
        public static void LineToPolygon(CCPoint[] points, float stroke, ccVertex2F[] vertices, int offset, int nuPoints)
        {
            int     num;
            CCPoint cCPoint;

            nuPoints = nuPoints + offset;
            if (nuPoints <= 1)
            {
                return;
            }
            stroke = stroke * 0.5f;
            int num1 = nuPoints - 1;

            for (int i = offset; i < nuPoints; i++)
            {
                num = i * 2;
                CCPoint cCPoint1 = points[i];
                if (i == 0)
                {
                    cCPoint = CCPointExtension.ccpPerp(CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(cCPoint1, points[i + 1])));
                }
                else if (i != num1)
                {
                    CCPoint cCPoint2 = points[i + 1];
                    CCPoint cCPoint3 = points[i - 1];
                    CCPoint cCPoint4 = CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(cCPoint2, cCPoint1));
                    CCPoint cCPoint5 = CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(cCPoint3, cCPoint1));
                    float   single   = (float)Math.Acos((double)CCPointExtension.ccpDot(cCPoint4, cCPoint5));
                    if (single >= ccMacros.CC_DEGREES_TO_RADIANS(70f))
                    {
                        cCPoint = (single >= ccMacros.CC_DEGREES_TO_RADIANS(170f) ? CCPointExtension.ccpPerp(CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(cCPoint2, cCPoint3))) : CCPointExtension.ccpNormalize(CCPointExtension.ccpMidpoint(cCPoint4, cCPoint5)));
                    }
                    else
                    {
                        cCPoint = CCPointExtension.ccpPerp(CCPointExtension.ccpNormalize(CCPointExtension.ccpMidpoint(cCPoint4, cCPoint5)));
                    }
                }
                else
                {
                    cCPoint = CCPointExtension.ccpPerp(CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(points[i - 1], cCPoint1)));
                }
                cCPoint           = CCPointExtension.ccpMult(cCPoint, stroke);
                vertices[num]     = new ccVertex2F(cCPoint1.x + cCPoint.x, cCPoint1.y + cCPoint.y);
                vertices[num + 1] = new ccVertex2F(cCPoint1.x - cCPoint.x, cCPoint1.y - cCPoint.y);
            }
            offset = (offset == 0 ? 0 : offset - 1);
            for (int j = offset; j < num1; j++)
            {
                num = j * 2;
                int        num2         = num + 2;
                ccVertex2F _ccVertex2F  = vertices[num];
                ccVertex2F _ccVertex2F1 = vertices[num + 1];
                ccVertex2F _ccVertex2F2 = vertices[num2];
                ccVertex2F _ccVertex2F3 = vertices[num2 + 1];
                float      single1      = 0f;
                bool       flag         = !CCVertex.LineIntersect(_ccVertex2F.x, _ccVertex2F.y, _ccVertex2F3.x, _ccVertex2F3.y, _ccVertex2F1.x, _ccVertex2F1.y, _ccVertex2F2.x, _ccVertex2F2.y, out single1);
                if (!flag && (single1 < 0f || single1 > 1f))
                {
                    flag = true;
                }
                if (flag)
                {
                    vertices[num2]     = _ccVertex2F3;
                    vertices[num2 + 1] = _ccVertex2F2;
                }
            }
        }
        public override void update(float delta)
        {
            if (!m_bStartingPositionInitialized)
            {
                return;
            }

            if (m_pVerticesPCT == null)
            {
                m_pVerticesPCT = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
            }
            if (m_uNuPoints * 2 > m_pVerticesPCT.Length)
            {
                VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
                m_pVerticesPCT.CopyTo(tmp, 0);
                m_pVerticesPCT = tmp;
            }
            delta *= m_fFadeDelta;

            int newIdx, newIdx2, i, i2;
            int mov = 0;

            // Update current points
            for (i = 0; i < m_uNuPoints; i++)
            {
                if (m_pVerticesPCT[i] == null)
                {
                    m_pVerticesPCT[i] = new VertexPositionColorTexture(m_pVertices[i].ToVector3(), m_pColor[i].XNAColor, m_pTexCoords[i].ToVector2());
                }
                if (m_pVerticesPCT[i * 2] == null)
                {
                    m_pVerticesPCT[i * 2] = new VertexPositionColorTexture(m_pVerticesPCT[i].Position, m_pVerticesPCT[i].Color, m_pVerticesPCT[i].TextureCoordinate);
                }
                m_pPointState[i] -= delta;

                if (m_pPointState[i] <= 0)
                {
                    mov++;
                }
                else
                {
                    newIdx = i - mov;

                    if (mov > 0)
                    {
                        // Move data
                        m_pPointState[newIdx] = m_pPointState[i];

                        // Move point
                        m_pPointVertexes[newIdx] = new CCPoint(m_pPointVertexes[i]);

                        // Move vertices
                        i2      = i * 2;
                        newIdx2 = newIdx * 2;
                        m_pVertices[newIdx2]     = new ccVertex2F(m_pVertices[i2]);
                        m_pVertices[newIdx2 + 1] = new ccVertex2F(m_pVertices[i2 + 1]);
                        // Move color
                        m_pColor[newIdx2]     = new ccColor4B(m_pColor[i2]);
                        m_pColor[newIdx2 + 1] = new ccColor4B(m_pColor[i2 + 1]);
                        // Move the GL vertex data
                        m_pVerticesPCT[newIdx2]     = m_pVerticesPCT[i2];
                        m_pVerticesPCT[newIdx2 + 1] = m_pVerticesPCT[i2 + 1];
                    }
                    else
                    {
                        newIdx2 = newIdx * 2;
                    }
                    byte op = (byte)(m_pPointState[newIdx] * 255.0f);
                    m_pColor[newIdx2].a     = op;
                    m_pColor[newIdx2 + 1].a = op;
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[newIdx2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2].ToVector3(), m_pColor[newIdx2].XNAColor, m_pTexCoords[newIdx2].ToVector2());
                        m_pVerticesPCT[newIdx2] = vpc;
                    }
                    if (m_pVertices[newIdx2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2 + 1].ToVector3(), m_pColor[newIdx2 + 1].XNAColor, m_pTexCoords[newIdx2 + 1].ToVector2());
                        m_pVerticesPCT[newIdx2 + 1] = vpc;
                    }
                }
            }
            m_uNuPoints -= mov;

            // Append new point
            bool appendNewPoint = true;

            if (m_uNuPoints >= m_uMaxPoints)
            {
                appendNewPoint = false;
            }

            else if (m_uNuPoints > 0)
            {
                bool a1 = (m_pPointVertexes[m_uNuPoints - 1].DistanceSQ(m_tPositionR) < m_fMinSeg);
                bool a2 = (m_uNuPoints == 1) ? false : (m_pPointVertexes[m_uNuPoints - 2].DistanceSQ(m_tPositionR) < (m_fMinSeg * 2.0f));
                if (a1 || a2)
                {
                    appendNewPoint = false;
                }
            }

            if (appendNewPoint)
            {
                m_pPointVertexes[m_uNuPoints] = new CCPoint(m_tPositionR);
                m_pPointState[m_uNuPoints]    = 1.0f;

                // Color asignment
                int offset = m_uNuPoints * 2;
                m_pColor[offset]     = new ccColor4B(m_tColor);
                m_pColor[offset + 1] = new ccColor4B(m_tColor);

                // Opacity
                m_pColor[offset].a     = 255;
                m_pColor[offset + 1].a = 255;

                // Generate polygon
                if (m_uNuPoints > 0 && m_bFastMode)
                {
                    if (m_uNuPoints > 1)
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_uNuPoints, 1);
                    }
                    else
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, 2);
                    }
                }

                m_uNuPoints++;
            }

            if (!m_bFastMode)
            {
                CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, m_uNuPoints);
            }

            // Updated Tex Coords only if they are different than previous step
            if (m_uPreviousNuPoints != m_uNuPoints)
            {
                if (m_uNuPoints > m_uPreviousNuPoints)
                {
                    int count = (m_uNuPoints + 1) * 2;
                    if (count < m_pVerticesPCT.Length)
                    {
                        count = m_pVerticesPCT.Length;
                    }
                    VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[count];
                    m_pVerticesPCT.CopyTo(tmp, 0);
                    m_pVerticesPCT = tmp;
                }
                float texDelta = 1.0f / m_uNuPoints;
                for (i = 0; i < m_uNuPoints; i++)
                {
                    m_pTexCoords[i * 2]     = new ccTex2F(0, texDelta * i);
                    m_pTexCoords[i * 2 + 1] = new ccTex2F(1, texDelta * i);
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[i * 2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2].ToVector3(), m_pColor[i * 2].XNAColor, m_pTexCoords[i * 2].ToVector2());
                        m_pVerticesPCT[i * 2] = vpc;
                    }
                    if (m_pVertices[i * 2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2 + 1].ToVector3(), m_pColor[i * 2 + 1].XNAColor, m_pTexCoords[i * 2 + 1].ToVector2());
                        m_pVerticesPCT[i * 2 + 1] = vpc;
                    }
                }

                m_uPreviousNuPoints = m_uNuPoints;
            }
        }
Example #37
0
 public bool initWithPosition(CCPoint pos)
 {
     m_tPosition = pos;
     return(true);
 }
Example #38
0
        // the XML parser calls here with all the elements
        public void startElement(object ctx, string name, string[] atts)
        {
            CCTMXMapInfo pTMXMapInfo = this;
            string       elementName = name;
            Dictionary <string, string> attributeDict = new Dictionary <string, string>();

            if (atts != null && atts[0] != null)
            {
                for (int i = 0; i + 1 < atts.Length; i += 2)
                {
                    string key   = atts[i];
                    string value = atts[i + 1];
                    attributeDict.Add(key, value);
                }
            }
            if (elementName == "map")
            {
                string version = attributeDict["version"];
                if (version != "1.0")
                {
                    CCLog.Log("cocos2d: TMXFormat: Unsupported TMX version: {0}", version);
                }
                string orientationStr = attributeDict["orientation"];
                if (orientationStr == "orthogonal")
                {
                    pTMXMapInfo.Orientation = (int)(CCTMXOrientatio.CCTMXOrientationOrtho);
                }
                else if (orientationStr == "isometric")
                {
                    pTMXMapInfo.Orientation = (int)(CCTMXOrientatio.CCTMXOrientationIso);
                }
                else if (orientationStr == "hexagonal")
                {
                    pTMXMapInfo.Orientation = (int)(CCTMXOrientatio.CCTMXOrientationHex);
                }
                else
                {
                    CCLog.Log("cocos2d: TMXFomat: Unsupported orientation: {0}", pTMXMapInfo.Orientation);
                }

                CCSize sMapSize = new CCSize();
                sMapSize.width      = ccUtils.ccParseFloat(attributeDict["width"]);
                sMapSize.height     = ccUtils.ccParseFloat(attributeDict["height"]);
                pTMXMapInfo.MapSize = sMapSize;

                CCSize sTileSize = new CCSize();
                sTileSize.width      = ccUtils.ccParseFloat(attributeDict["tilewidth"]);
                sTileSize.height     = ccUtils.ccParseFloat(attributeDict["tileheight"]);
                pTMXMapInfo.TileSize = sTileSize;

                // The parent element is now "map"
                pTMXMapInfo.ParentElement = (int)TMXProperty.TMXPropertyMap;
            }
            else if (elementName == "tileset")
            {
                // If this is an external tileset then start parsing that

                if (attributeDict.Keys.Contains("source"))
                {
                    string externalTilesetFilename = attributeDict["source"];

                    externalTilesetFilename = CCFileUtils.fullPathFromRelativeFile(externalTilesetFilename, pTMXMapInfo.TMXFileName);
                    pTMXMapInfo.parseXMLFile(externalTilesetFilename);
                }
                else
                {
                    CCTMXTilesetInfo tileset = new CCTMXTilesetInfo();
                    tileset.m_sName     = attributeDict["name"];
                    tileset.m_uFirstGid = ccUtils.ccParseInt(attributeDict["firstgid"]);

                    if (attributeDict.Keys.Contains("spacing"))
                    {
                        tileset.m_uSpacing = ccUtils.ccParseInt(attributeDict["spacing"]);
                    }

                    if (attributeDict.Keys.Contains("margin"))
                    {
                        tileset.m_uMargin = ccUtils.ccParseInt(attributeDict["margin"]);
                    }
                    CCSize s = new CCSize();
                    s.width             = ccUtils.ccParseFloat(attributeDict["tilewidth"]);
                    s.height            = ccUtils.ccParseFloat(attributeDict["tileheight"]);
                    tileset.m_tTileSize = s;

                    pTMXMapInfo.Tilesets.Add(tileset);
                }
            }
            else if (elementName == "tile")
            {
                CCTMXTilesetInfo            info = pTMXMapInfo.Tilesets.LastOrDefault();
                Dictionary <string, string> dict = new Dictionary <string, string>();
                pTMXMapInfo.ParentGID = (info.m_uFirstGid + ccUtils.ccParseInt(attributeDict["id"]));
                pTMXMapInfo.TileProperties.Add(pTMXMapInfo.ParentGID, dict);

                pTMXMapInfo.ParentElement = (int)TMXProperty.TMXPropertyTile;
            }
            else if (elementName == "layer")
            {
                CCTMXLayerInfo layer = new CCTMXLayerInfo();
                layer.m_sName = attributeDict["name"];

                CCSize s = new CCSize();
                s.width            = ccUtils.ccParseFloat(attributeDict["width"]);
                s.height           = ccUtils.ccParseFloat(attributeDict["height"]);
                layer.m_tLayerSize = s;

                layer.m_pTiles = new int[(int)s.width * (int)s.height];

                if (attributeDict.Keys.Contains("visible"))
                {
                    string visible = attributeDict["visible"];
                    layer.m_bVisible = !(visible == "0");
                }
                else
                {
                    layer.m_bVisible = true;
                }

                if (attributeDict.Keys.Contains("opacity"))
                {
                    string opacity = attributeDict["opacity"];
                    layer.m_cOpacity = (byte)(255 * ccUtils.ccParseFloat(opacity));
                }
                else
                {
                    layer.m_cOpacity = 255;
                }

                float x = attributeDict.Keys.Contains("x") ? ccUtils.ccParseFloat(attributeDict["x"]) : 0;
                float y = attributeDict.Keys.Contains("y") ? ccUtils.ccParseFloat(attributeDict["y"]) : 0;
                layer.m_tOffset = new CCPoint(x, y);

                pTMXMapInfo.Layers.Add(layer);

                // The parent element is now "layer"
                pTMXMapInfo.ParentElement = (int)TMXProperty.TMXPropertyLayer;
            }
            else if (elementName == "objectgroup")
            {
                CCTMXObjectGroup objectGroup = new CCTMXObjectGroup();
                objectGroup.GroupName = attributeDict["name"];
                CCPoint positionOffset = new CCPoint();
                if (attributeDict.ContainsKey("x"))
                {
                    positionOffset.x = ccUtils.ccParseFloat(attributeDict["x"]) * pTMXMapInfo.TileSize.width;
                }
                if (attributeDict.ContainsKey("y"))
                {
                    positionOffset.y = ccUtils.ccParseFloat(attributeDict["y"]) * pTMXMapInfo.TileSize.height;
                }
                objectGroup.PositionOffset = positionOffset;

                pTMXMapInfo.ObjectGroups.Add(objectGroup);

                // The parent element is now "objectgroup"
                pTMXMapInfo.ParentElement = (int)TMXProperty.TMXPropertyObjectGroup;
            }
            else if (elementName == "image")
            {
                CCTMXTilesetInfo tileset = pTMXMapInfo.Tilesets.LastOrDefault();

                // build full path
                string imagename = attributeDict["source"];
                tileset.m_sSourceImage = CCFileUtils.fullPathFromRelativeFile(imagename, pTMXMapInfo.TMXFileName);
            }
            else if (elementName == "data")
            {
                string encoding    = attributeDict.ContainsKey("encoding") ? attributeDict["encoding"] : "";
                string compression = attributeDict.ContainsKey("compression") ? attributeDict["compression"] : "";

                if (encoding == "base64")
                {
                    int layerAttribs = pTMXMapInfo.LayerAttribs;
                    pTMXMapInfo.LayerAttribs      = layerAttribs | (int)TMXLayerAttrib.TMXLayerAttribBase64;
                    pTMXMapInfo.StoringCharacters = true;

                    if (compression == "gzip")
                    {
                        layerAttribs             = pTMXMapInfo.LayerAttribs;
                        pTMXMapInfo.LayerAttribs = layerAttribs | (int)TMXLayerAttrib.TMXLayerAttribGzip;
                    }
                    else
                    if (compression == "zlib")
                    {
                        layerAttribs             = pTMXMapInfo.LayerAttribs;
                        pTMXMapInfo.LayerAttribs = layerAttribs | (int)TMXLayerAttrib.TMXLayerAttribZlib;
                    }
                    Debug.Assert(compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method");
                }
                Debug.Assert(pTMXMapInfo.LayerAttribs != (int)TMXLayerAttrib.TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported");
            }
            else if (elementName == "object")
            {
                char[]           buffer      = new char[32];
                CCTMXObjectGroup objectGroup = pTMXMapInfo.ObjectGroups.LastOrDefault();

                // The value for "type" was blank or not a valid class name
                // Create an instance of TMXObjectInfo to store the object and its properties
                Dictionary <string, string> dict = new Dictionary <string, string>();

                // Set the name of the object to the value for "name"
                string key   = "name";
                string value = attributeDict.ContainsKey("name") ? attributeDict["name"] : "";
                dict.Add(key, value);

                // Assign all the attributes as key/name pairs in the properties dictionary
                key   = "type";
                value = attributeDict.ContainsKey("type") ? attributeDict["type"] : "";
                dict.Add(key, value);

                int x = ccUtils.ccParseInt(attributeDict["x"]) + (int)objectGroup.PositionOffset.x;
                key   = "x";
                value = x.ToString();
                dict.Add(key, value);

                int y = ccUtils.ccParseInt(attributeDict["y"]) + (int)objectGroup.PositionOffset.y;
                // Correct y position. (Tiled uses Flipped, cocos2d uses Standard)
                y     = (int)(pTMXMapInfo.MapSize.height * pTMXMapInfo.TileSize.height) - y - (attributeDict.ContainsKey("height") ? ccUtils.ccParseInt(attributeDict["height"]) : 0);
                key   = "y";
                value = y.ToString();
                dict.Add(key, value);

                key   = "width";
                value = attributeDict.ContainsKey("width") ? attributeDict["width"] : "";
                dict.Add(key, value);

                key   = "height";
                value = attributeDict.ContainsKey("height") ? attributeDict["height"] : "";
                dict.Add(key, value);

                // Add the object to the objectGroup
                objectGroup.Objects.Add(dict);

                // The parent element is now "object"
                pTMXMapInfo.ParentElement = (int)TMXProperty.TMXPropertyObject;
            }
            else if (elementName == "property")
            {
                if (pTMXMapInfo.ParentElement == (int)TMXProperty.TMXPropertyNone)
                {
                    CCLog.Log("TMX tile map: Parent element is unsupported. Cannot add property named '{0}' with value '{1}'",
                              attributeDict["name"], attributeDict["value"]);
                }
                else if (pTMXMapInfo.ParentElement == (int)TMXProperty.TMXPropertyMap)
                {
                    // The parent element is the map
                    string value = attributeDict["value"];
                    string key   = attributeDict["name"];
                    pTMXMapInfo.Properties.Add(key, value);
                }
                else if (pTMXMapInfo.ParentElement == (int)TMXProperty.TMXPropertyLayer)
                {
                    // The parent element is the last layer
                    CCTMXLayerInfo layer = pTMXMapInfo.Layers.LastOrDefault();
                    string         value = attributeDict["value"];
                    string         key   = attributeDict["name"];
                    // Add the property to the layer
                    layer.Properties.Add(key, value);
                }
                else if (pTMXMapInfo.ParentElement == (int)TMXProperty.TMXPropertyObjectGroup)
                {
                    // The parent element is the last object group
                    CCTMXObjectGroup objectGroup = pTMXMapInfo.ObjectGroups.LastOrDefault();
                    string           value       = attributeDict["value"];
                    string           key         = attributeDict["name"];
                    objectGroup.Properties.Add(key, value);
                }
                else if (pTMXMapInfo.ParentElement == (int)TMXProperty.TMXPropertyObject)
                {
                    // The parent element is the last object
                    CCTMXObjectGroup            objectGroup = pTMXMapInfo.ObjectGroups.LastOrDefault();
                    Dictionary <string, string> dict        = objectGroup.Objects.LastOrDefault();

                    string propertyName  = attributeDict["name"];
                    string propertyValue = attributeDict["value"];
                    dict.Add(propertyName, propertyValue);
                }
                else if (pTMXMapInfo.ParentElement == (int)TMXProperty.TMXPropertyTile)
                {
                    Dictionary <string, string> dict = pTMXMapInfo.TileProperties[pTMXMapInfo.ParentGID];

                    string propertyName  = attributeDict["name"];
                    string propertyValue = attributeDict["value"];
                    dict.Add(propertyName, propertyValue);
                }
            }
            if (attributeDict != null)
            {
                attributeDict = null;
            }
        }
Example #39
0
        /// <summary>
        /// Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
        /// The originalSize is the size in points of the frame before being trimmed.
        /// </summary>
        public static CCSpriteFrame frameWithTexture(CCTexture2D pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize)
        {
            CCSpriteFrame pSpriteFrame = new CCSpriteFrame();

            pSpriteFrame.initWithTexture(pobTexture, rect, rotated, offset, originalSize);

            return(pSpriteFrame);
        }
Example #40
0
        public void initParticle(CCParticle particle)
        {
            particle.timeToLive = this.m_fLife + (this.m_fLifeVar * ccMacros.CCRANDOM_MINUS1_1());
            particle.timeToLive = (0f > particle.timeToLive) ? 0f : particle.timeToLive;
            particle.pos.x      = this.m_tSourcePosition.x + (this.m_tPosVar.x * ccMacros.CCRANDOM_MINUS1_1());
            particle.pos.x     *= CCDirector.sharedDirector().ContentScaleFactor;
            particle.pos.y      = this.m_tSourcePosition.y + (this.m_tPosVar.y * ccMacros.CCRANDOM_MINUS1_1());
            particle.pos.y     *= CCDirector.sharedDirector().ContentScaleFactor;
            ccColor4F colorf = new ccColor4F
            {
                r = CCPointExtension.clampf(this.m_tStartColor.r + (this.m_tStartColorVar.r * ccMacros.CCRANDOM_MINUS1_1()), 0f, 1f),
                g = CCPointExtension.clampf(this.m_tStartColor.g + (this.m_tStartColorVar.g * ccMacros.CCRANDOM_MINUS1_1()), 0f, 1f),
                b = CCPointExtension.clampf(this.m_tStartColor.b + (this.m_tStartColorVar.b * ccMacros.CCRANDOM_MINUS1_1()), 0f, 1f),
                a = CCPointExtension.clampf(this.m_tStartColor.a + (this.m_tStartColorVar.a * ccMacros.CCRANDOM_MINUS1_1()), 0f, 1f)
            };
            ccColor4F colorf2 = new ccColor4F
            {
                r = CCPointExtension.clampf(this.m_tEndColor.r + (this.m_tEndColorVar.r * ccMacros.CCRANDOM_MINUS1_1()), 0f, 1f),
                g = CCPointExtension.clampf(this.m_tEndColor.g + (this.m_tEndColorVar.g * ccMacros.CCRANDOM_MINUS1_1()), 0f, 1f),
                b = CCPointExtension.clampf(this.m_tEndColor.b + (this.m_tEndColorVar.b * ccMacros.CCRANDOM_MINUS1_1()), 0f, 1f),
                a = CCPointExtension.clampf(this.m_tEndColor.a + (this.m_tEndColorVar.a * ccMacros.CCRANDOM_MINUS1_1()), 0f, 1f)
            };

            particle.color        = colorf;
            particle.deltaColor.r = (colorf2.r - colorf.r) / particle.timeToLive;
            particle.deltaColor.g = (colorf2.g - colorf.g) / particle.timeToLive;
            particle.deltaColor.b = (colorf2.b - colorf.b) / particle.timeToLive;
            particle.deltaColor.a = (colorf2.a - colorf.a) / particle.timeToLive;
            float num = this.m_fStartSize + (this.m_fStartSizeVar * ccMacros.CCRANDOM_MINUS1_1());

            num           = (0f > num) ? 0f : num;
            num          *= CCDirector.sharedDirector().ContentScaleFactor;
            particle.size = num;
            if (this.m_fEndSize == -1f)
            {
                particle.deltaSize = 0f;
            }
            else
            {
                float num2 = this.m_fEndSize + (this.m_fEndSizeVar * ccMacros.CCRANDOM_MINUS1_1());
                num2  = (0f > num2) ? 0f : num2;
                num2 *= CCDirector.sharedDirector().ContentScaleFactor;
                particle.deltaSize = (num2 - num) / particle.timeToLive;
            }
            float num3 = this.m_fStartSpin + (this.m_fStartSpinVar * ccMacros.CCRANDOM_MINUS1_1());
            float num4 = this.m_fEndSpin + (this.m_fEndSpinVar * ccMacros.CCRANDOM_MINUS1_1());

            particle.rotation      = num3;
            particle.deltaRotation = (num4 - num3) / particle.timeToLive;
            if (this.m_ePositionType == eParticlePositionType.kCCPositionTypeFree)
            {
                CCPoint v = base.convertToWorldSpace(new CCPoint(0f, 0f));
                particle.startPos = CCPointExtension.ccpMult(v, CCDirector.sharedDirector().ContentScaleFactor);
            }
            else if (this.m_ePositionType == eParticlePositionType.kCCPositionTypeRelative)
            {
                particle.startPos = CCPointExtension.ccpMult(base.m_tPosition, CCDirector.sharedDirector().ContentScaleFactor);
            }
            float num5 = ccMacros.CC_DEGREES_TO_RADIANS(this.m_fAngle + (this.m_fAngleVar * ccMacros.CCRANDOM_MINUS1_1()));

            if (this.m_nEmitterMode == 0)
            {
                CCPoint point2 = new CCPoint((float)Math.Cos((double)num5), (float)Math.Sin((double)num5));
                float   s      = this.modeA.speed + (this.modeA.speedVar * ccMacros.CCRANDOM_MINUS1_1());
                s *= CCDirector.sharedDirector().ContentScaleFactor;
                particle.modeA.dir              = CCPointExtension.ccpMult(point2, s);
                particle.modeA.radialAccel      = this.modeA.radialAccel + (this.modeA.radialAccelVar * ccMacros.CCRANDOM_MINUS1_1());
                particle.modeA.radialAccel     *= CCDirector.sharedDirector().ContentScaleFactor;
                particle.modeA.tangentialAccel  = this.modeA.tangentialAccel + (this.modeA.tangentialAccelVar * ccMacros.CCRANDOM_MINUS1_1());
                particle.modeA.tangentialAccel *= CCDirector.sharedDirector().ContentScaleFactor;
            }
            else
            {
                float num7 = this.modeB.startRadius + (this.modeB.startRadiusVar * ccMacros.CCRANDOM_MINUS1_1());
                float num8 = this.modeB.endRadius + (this.modeB.endRadiusVar * ccMacros.CCRANDOM_MINUS1_1());
                num7 *= CCDirector.sharedDirector().ContentScaleFactor;
                num8 *= CCDirector.sharedDirector().ContentScaleFactor;
                particle.modeB.radius = num7;
                if (this.modeB.endRadius == -1f)
                {
                    particle.modeB.deltaRadius = 0f;
                }
                else
                {
                    particle.modeB.deltaRadius = (num8 - num7) / particle.timeToLive;
                }
                particle.modeB.angle            = num5;
                particle.modeB.degreesPerSecond = ccMacros.CC_DEGREES_TO_RADIANS(this.modeB.rotatePerSecond + (this.modeB.rotatePerSecondVar * ccMacros.CCRANDOM_MINUS1_1()));
            }
        }
        public void addSpriteFramesWithDictionary(Dictionary <string, object> pobDictionary, CCTexture2D pobTexture)
        {
            Dictionary <string, object> item = null;

            if (pobDictionary.Keys.Contains <string>("metadata"))
            {
                item = (Dictionary <string, object>)pobDictionary["metadata"];
            }
            Dictionary <string, object> strs = null;

            if (pobDictionary.Keys.Contains <string>("frames"))
            {
                strs = (Dictionary <string, object>)pobDictionary["frames"];
            }
            int num = 0;

            if (item != null)
            {
                num = ccUtils.ccParseInt(item["format"].ToString());
            }
            foreach (string key in strs.Keys)
            {
                Dictionary <string, object> item1 = strs[key] as Dictionary <string, object>;
                CCSpriteFrame cCSpriteFrame       = new CCSpriteFrame();
                if (num == 0)
                {
                    float single  = ccUtils.ccParseFloat(item1["x"].ToString());
                    float single1 = ccUtils.ccParseFloat(item1["y"].ToString());
                    float single2 = ccUtils.ccParseFloat(item1["width"].ToString());
                    float single3 = ccUtils.ccParseFloat(item1["height"].ToString());
                    float single4 = ccUtils.ccParseFloat(item1["offsetX"].ToString());
                    float single5 = ccUtils.ccParseFloat(item1["offsetY"].ToString());
                    int   num1    = ccUtils.ccParseInt(item1["originalWidth"].ToString());
                    int   num2    = ccUtils.ccParseInt(item1["originalHeight"].ToString());
                    if (num1 == 0 || num2 == 0)
                    {
                        CCLog.Log("cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist");
                    }
                    num1          = Math.Abs(num1);
                    num2          = Math.Abs(num2);
                    cCSpriteFrame = new CCSpriteFrame();
                    cCSpriteFrame.initWithTexture(pobTexture, new CCRect(single, single1, single2, single3), false, new CCPoint(single4, single5), new CCSize((float)num1, (float)num2));
                }
                else if (num == 1 || num == 2)
                {
                    CCRect cCRect = CCNS.CCRectFromString(item1["frame"].ToString());
                    bool   flag   = false;
                    if (num == 2 && item1.Keys.Contains <string>("rotated"))
                    {
                        flag = (ccUtils.ccParseInt(this.valueForKey("rotated", item1)) == 0 ? false : true);
                    }
                    CCPoint cCPoint = CCNS.CCPointFromString(this.valueForKey("offset", item1));
                    CCSize  cCSize  = CCNS.CCSizeFromString(this.valueForKey("sourceSize", item1));
                    cCSpriteFrame = new CCSpriteFrame();
                    cCSpriteFrame.initWithTexture(pobTexture, cCRect, flag, cCPoint, cCSize);
                }
                else if (num == 3)
                {
                    CCSize  cCSize1  = CCNS.CCSizeFromString(this.valueForKey("spriteSize", item1));
                    CCPoint cCPoint1 = CCNS.CCPointFromString(this.valueForKey("spriteOffset", item1));
                    CCSize  cCSize2  = CCNS.CCSizeFromString(this.valueForKey("spriteSourceSize", item1));
                    CCRect  cCRect1  = CCNS.CCRectFromString(this.valueForKey("textureRect", item1));
                    bool    flag1    = false;
                    if (item1.Keys.Contains <string>("textureRotated"))
                    {
                        flag1 = (ccUtils.ccParseInt(this.valueForKey("textureRotated", item1)) == 0 ? false : true);
                    }
                    object        obj  = item1["aliases"];
                    List <object> objs = item1["aliases"] as List <object>;
                    string        str  = key;
                    foreach (object obj1 in objs)
                    {
                        string str1 = obj1.ToString();
                        if (this.m_pSpriteFramesAliases.Keys.Contains <string>(str1) && this.m_pSpriteFramesAliases[str1] != null)
                        {
                            CCLog.Log("cocos2d: WARNING: an alias with name {0} already exists", new object[] { str1 });
                        }
                        if (this.m_pSpriteFramesAliases.Keys.Contains <string>(str))
                        {
                            continue;
                        }
                        this.m_pSpriteFramesAliases.Add(str, str1);
                    }
                    cCSpriteFrame = new CCSpriteFrame();
                    cCSpriteFrame.initWithTexture(pobTexture, new CCRect(cCRect1.origin.x, cCRect1.origin.y, cCSize1.width, cCSize1.height), flag1, cCPoint1, cCSize2);
                }
                if (this.m_pSpriteFrames.Keys.Contains <string>(key))
                {
                    continue;
                }
                this.m_pSpriteFrames.Add(key, cCSpriteFrame);
            }
        }
Example #42
0
 public void setGravity(CCPoint g)
 {
     this.modeA.gravity = g;
 }
Example #43
0
        private CCPoint ConvertToWindowSpace(CCPoint nodePoint)
        {
            CCPoint worldPoint = this.ConvertToWorldSpace(nodePoint);

            return(Director.SharedDirector.ConvertToUI(worldPoint));
        }
Example #44
0
        public override bool initWithTotalParticles(uint numberOfParticles)
        {
            if (base.initWithTotalParticles(numberOfParticles))
            {
                // duration
                Duration = (float)eParticleShowingProperty.kCCParticleDurationInfinity;

                // Emitter mode: Gravity Mode
                EmitterMode = (int)eParticleMode.kCCParticleModeGravity;

                // Gravity Mode: gravity
                modeA.gravity = new CCPoint(0, 0);

                // Gravity Mode: radial acceleration
                modeA.radialAccel    = 0;
                modeA.radialAccelVar = 0;

                // Gravity Mode: speed of particles
                modeA.speed    = 25;
                modeA.speedVar = 10;

                // angle
                Angle    = 90;
                AngleVar = 5;

                // emitter position
                CCSize winSize = CCDirector.sharedDirector().getWinSize();
                this.position = new CCPoint(winSize.width / 2, 0);
                PosVar        = new CCPoint(20, 0);

                // life of particles
                Life    = 4;
                LifeVar = 1;

                // size, in pixels
                StartSize    = 60.0f;
                StartSizeVar = 10.0f;
                EndSize      = (float)eParticleShowingProperty.kCCParticleStartSizeEqualToEndSize;

                // emits per frame
                EmissionRate = TotalParticles / Life;

                // color of particles
                StartColor.r    = 0.8f;
                StartColor.g    = 0.8f;
                StartColor.b    = 0.8f;
                StartColor.a    = 1.0f;
                StartColorVar.r = 0.02f;
                StartColorVar.g = 0.02f;
                StartColorVar.b = 0.02f;
                StartColorVar.a = 0.0f;
                EndColor.r      = 0.0f;
                EndColor.g      = 0.0f;
                EndColor.b      = 0.0f;
                EndColor.a      = 1.0f;
                EndColorVar.r   = 0.0f;
                EndColorVar.g   = 0.0f;
                EndColorVar.b   = 0.0f;
                EndColorVar.a   = 0.0f;

                // additive
                this.IsBlendAdditive = false;
                return(true);
            }
            return(false);
        }
Example #45
0
 public virtual void updatePosition(CCPoint newPos)
 {
     m_pTarget.position = new CCPoint(newPos);
 }
        public override void updateQuadWithParticle(CCParticle particle, CCPoint newPosition)
        {
            // colors
            ccV2F_C4B_T2F_Quad quad = m_pQuads[m_uParticleIdx];

            ccColor4B color = new ccColor4B((Byte)(particle.color.r * 255), (Byte)(particle.color.g * 255), (Byte)(particle.color.b * 255),
                                            (Byte)(particle.color.a * 255));

            quad.bl.colors = color;
            quad.br.colors = color;
            quad.tl.colors = color;
            quad.tr.colors = color;

            // vertices
            float size_2 = particle.size / 2;

            if (particle.rotation != 0)
            {
                float x1 = -size_2;
                float y1 = -size_2;

                float x2 = size_2;
                float y2 = size_2;
                float x  = newPosition.x;
                float y  = newPosition.y;

                float r  = -ccMacros.CC_DEGREES_TO_RADIANS(particle.rotation);
                float cr = (float)System.Math.Cos(r);
                float sr = (float)System.Math.Sin(r);
                float ax = x1 * cr - y1 * sr + x;
                float ay = x1 * sr + y1 * cr + y;
                float bx = x2 * cr - y1 * sr + x;
                float by = x2 * sr + y1 * cr + y;
                float cx = x2 * cr - y2 * sr + x;
                float cy = x2 * sr + y2 * cr + y;
                float dx = x1 * cr - y2 * sr + x;
                float dy = x1 * sr + y2 * cr + y;

                // bottom-left
                quad.bl.vertices.x = ax;
                quad.bl.vertices.y = ay;

                // bottom-right vertex:
                quad.br.vertices.x = bx;
                quad.br.vertices.y = by;

                // top-left vertex:
                quad.tl.vertices.x = dx;
                quad.tl.vertices.y = dy;

                // top-right vertex:
                quad.tr.vertices.x = cx;
                quad.tr.vertices.y = cy;
            }
            else
            {
                // bottom-left vertex:
                quad.bl.vertices.x = newPosition.x - size_2;
                quad.bl.vertices.y = newPosition.y - size_2;

                // bottom-right vertex:
                quad.br.vertices.x = newPosition.x + size_2;
                quad.br.vertices.y = newPosition.y - size_2;

                // top-left vertex:
                quad.tl.vertices.x = newPosition.x - size_2;
                quad.tl.vertices.y = newPosition.y + size_2;

                // top-right vertex:
                quad.tr.vertices.x = newPosition.x + size_2;
                quad.tr.vertices.y = newPosition.y + size_2;
            }
        }
Example #47
0
 public static void ccDrawPoints(CCPoint points, int numberOfPoints)
 {
     throw new NotImplementedException();
 }
        public override void draw()
        {
            base.draw();

            BlendState oldBlendState = CCApplication.sharedApplication().GraphicsDevice.BlendState;

            BlendState eBlendState = BlendState.AlphaBlend;

            if (this.IsBlendAdditive)
            {
                eBlendState = BlendState.Additive;
            }

            CCApplication.sharedApplication().spriteBatch.Begin(SpriteSortMode.Deferred, eBlendState);
            for (int i = 0; i < this.ParticleCount; i++)
            {
                CCParticle particle = m_pParticles[i];

                CCPoint uiPoint = CCAffineTransform.CCPointApplyAffineTransform(new CCPoint(), this.nodeToWorldTransform());
                uiPoint = CCPointExtension.ccpAdd(uiPoint, new CCPoint(m_pQuads[i].bl.vertices.x, m_pQuads[i].bl.vertices.y));
                uiPoint = CCDirector.sharedDirector().convertToUI(uiPoint);

                Vector2 vecPosition = new Vector2(uiPoint.x, uiPoint.y);

                Color color = new Color(particle.color.r,
                                        particle.color.g,
                                        particle.color.b,
                                        particle.color.a);

                float scale = 1.0f;
                if (Texture.getTexture2D().Width > Texture.getTexture2D().Height)
                {
                    scale = particle.size / Texture.getTexture2D().Height;
                }
                else
                {
                    scale = particle.size / Texture.getTexture2D().Width;
                }

                float rotation = particle.rotation;

                Vector2 origin = new Vector2(Texture.getTexture2D().Width / 2, Texture.getTexture2D().Height / 2);
                CCApplication.sharedApplication().spriteBatch.Draw(this.Texture.getTexture2D(), vecPosition, null, color, rotation, origin, scale, SpriteEffects.None, 0);


                //CCPoint uiPoint = CCAffineTransform.CCPointApplyAffineTransform(new CCPoint(), this.nodeToWorldTransform());
                //uiPoint.x += m_pQuads[i].bl.vertices.x;
                //uiPoint.y += m_pQuads[i].bl.vertices.y;
                //uiPoint = CCDirector.sharedDirector().convertToUI(uiPoint);
                //Vector2 vecPosition = new Vector2(uiPoint.x, uiPoint.y);

                //Color color = new Color(m_pQuads[i].bl.colors.r,
                //                        m_pQuads[i].bl.colors.g,
                //                        m_pQuads[i].bl.colors.b,
                //                        m_pQuads[i].bl.colors.a);

                //Vector2 origin = new Vector2(Texture.getTexture2D().Width/2, Texture.getTexture2D().Height/2);
                //CCApplication.sharedApplication().spriteBatch.Draw(this.Texture.getTexture2D(), vecPosition, null, color, 0, origin, 1.0f, SpriteEffects.None, 0);
            }
            CCApplication.sharedApplication().spriteBatch.End();

            CCApplication.sharedApplication().GraphicsDevice.BlendState = oldBlendState;

            //    // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
            //    // Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
            //    // Unneeded states: -
            //    glBindTexture(GL_TEXTURE_2D, m_pTexture->getName());

            //    #define kQuadSize sizeof(m_pQuads[0].bl)


            //    int offset = (int) m_pQuads;

            //    // vertex
            //    int diff = offsetof( ccV2F_C4B_T2F, vertices);
            //    glVertexPointer(2,GL_FLOAT, kQuadSize, (GLvoid*) (offset+diff) );

            //    // color
            //    diff = offsetof( ccV2F_C4B_T2F, colors);
            //    glColorPointer(4, GL_UNSIGNED_BYTE, kQuadSize, (GLvoid*)(offset + diff));

            //    // tex coords
            //    diff = offsetof( ccV2F_C4B_T2F, texCoords);
            //    glTexCoordPointer(2, GL_FLOAT, kQuadSize, (GLvoid*)(offset + diff));


            //    bool newBlend = (m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST) ? true : false;
            //    if( newBlend )
            //    {
            //        glBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
            //    }

            //    CCAssert( m_uParticleIdx == m_uParticleCount, "Abnormal error in particle quad");

            //    glDrawElements(GL_TRIANGLES, (GLsizei)(m_uParticleIdx*6), GL_UNSIGNED_SHORT, m_pIndices);

            //    // restore blend state
            //    if( newBlend )
            //        glBlendFunc( CC_BLEND_SRC, CC_BLEND_DST );

            //#if CC_USES_VBO
            //    glBindBuffer(GL_ARRAY_BUFFER, 0);
            //#endif
        }
Example #49
0
        public override void update(float dt)
        {
            if (this.m_bIsActive && (this.m_fEmissionRate != 0f))
            {
                float num = 1f / this.m_fEmissionRate;
                this.m_fEmitCounter += dt;
                while ((this.m_uParticleCount < this.m_uTotalParticles) && (this.m_fEmitCounter > num))
                {
                    this.addParticle();
                    this.m_fEmitCounter -= num;
                }
                this.m_fElapsed += dt;
                if ((this.m_fDuration != -1f) && (this.m_fDuration < this.m_fElapsed))
                {
                    this.stopSystem();
                }
            }
            this.m_uParticleIdx = 0;
            CCPoint tPosition = new CCPoint(0f, 0f);

            if (this.m_ePositionType == eParticlePositionType.kCCPositionTypeFree)
            {
                tPosition    = base.convertToWorldSpace(new CCPoint(0f, 0f));
                tPosition.x *= CCDirector.sharedDirector().ContentScaleFactor;
                tPosition.y *= CCDirector.sharedDirector().ContentScaleFactor;
            }
            else if (this.m_ePositionType == eParticlePositionType.kCCPositionTypeRelative)
            {
                tPosition    = base.m_tPosition;
                tPosition.x *= CCDirector.sharedDirector().ContentScaleFactor;
                tPosition.y *= CCDirector.sharedDirector().ContentScaleFactor;
            }
            while (this.m_uParticleIdx < this.m_uParticleCount)
            {
                CCParticle particle = this.m_pParticles[this.m_uParticleIdx];
                particle.timeToLive -= dt;
                if (particle.timeToLive > 0f)
                {
                    CCPoint pos;
                    if (this.m_nEmitterMode == 0)
                    {
                        CCPoint v = new CCPoint(0f, 0f);
                        if ((particle.pos.x != 0f) || (particle.pos.y != 0f))
                        {
                            v = CCPointExtension.ccpNormalize(particle.pos);
                        }
                        CCPoint point4 = v;
                        v = CCPointExtension.ccpMult(v, particle.modeA.radialAccel);
                        float x = point4.x;
                        point4.x = -point4.y;
                        point4.y = x;
                        point4   = CCPointExtension.ccpMult(point4, particle.modeA.tangentialAccel);
                        CCPoint point2 = CCPointExtension.ccpMult(CCPointExtension.ccpAdd(CCPointExtension.ccpAdd(v, point4), this.modeA.gravity), dt);
                        particle.modeA.dir = CCPointExtension.ccpAdd(particle.modeA.dir, point2);
                        point2             = CCPointExtension.ccpMult(particle.modeA.dir, dt);
                        particle.pos       = CCPointExtension.ccpAdd(particle.pos, point2);
                    }
                    else
                    {
                        particle.modeB.angle  += particle.modeB.degreesPerSecond * dt;
                        particle.modeB.radius += particle.modeB.deltaRadius * dt;
                        particle.pos.x         = -((float)Math.Cos((double)particle.modeB.angle)) * particle.modeB.radius;
                        particle.pos.y         = -((float)Math.Sin((double)particle.modeB.angle)) * particle.modeB.radius;
                    }
                    particle.color.r  += particle.deltaColor.r * dt;
                    particle.color.g  += particle.deltaColor.g * dt;
                    particle.color.b  += particle.deltaColor.b * dt;
                    particle.color.a  += particle.deltaColor.a * dt;
                    particle.size     += particle.deltaSize * dt;
                    particle.size      = (0f > particle.size) ? 0f : particle.size;
                    particle.rotation += particle.deltaRotation * dt;
                    if ((this.m_ePositionType == eParticlePositionType.kCCPositionTypeFree) || (this.m_ePositionType == eParticlePositionType.kCCPositionTypeRelative))
                    {
                        CCPoint point6 = CCPointExtension.ccpSub(tPosition, particle.startPos);
                        pos = CCPointExtension.ccpSub(particle.pos, point6);
                    }
                    else
                    {
                        pos = particle.pos;
                    }
                    this.updateQuadWithParticle(particle, pos);
                    this.m_uParticleIdx++;
                }
                else
                {
                    if (this.m_uParticleIdx != (this.m_uParticleCount - 1))
                    {
                        this.m_pParticles[this.m_uParticleIdx].copy(this.m_pParticles[(int)((IntPtr)(this.m_uParticleCount - 1))]);
                    }
                    this.m_uParticleCount--;
                    if ((this.m_uParticleCount == 0) && this.m_bIsAutoRemoveOnFinish)
                    {
                        base.unscheduleUpdate();
                        base.m_pParent.removeChild(this, true);
                        return;
                    }
                }
            }
            this.postStep();
        }
Example #50
0
        /// <summary>
        /// Initializes a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
        /// The originalSize is the size in points of the frame before being trimmed.
        /// </summary>
        public bool initWithTexture(CCTexture2D pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize)
        {
            m_pobTexture = pobTexture;

            m_obRectInPixels   = rect;
            m_obRect           = ccMacros.CC_RECT_PIXELS_TO_POINTS(rect);
            m_bRotated         = rotated;
            m_obOffsetInPixels = offset;

            m_obOriginalSizeInPixels = originalSize;

            return(true);
        }
Example #51
0
 public sModeA()
 {
     this.dir = new CCPoint();
 }
Example #52
0
 public virtual void updateQuadWithParticle(CCParticle particle, CCPoint newPosition)
 {
 }
Example #53
0
 public static void ccDrawPoint(CCPoint point)
 {
 }
Example #54
0
        public static void LineToPolygon(CCPoint[] points, float stroke, ccVertex2F[] vertices, int offset, int nuPoints)
        {
            nuPoints += offset;
            if (nuPoints <= 1)
            {
                return;
            }

            stroke *= 0.5f;

            int idx;
            int nuPointsMinus = nuPoints - 1;

            for (int i = offset; i < nuPoints; i++)
            {
                idx = i * 2;
                CCPoint p1 = points[i];
                CCPoint perpVector;

                if (i == 0)
                {
                    perpVector = CCPointExtension.ccpPerp(CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(p1, points[i + 1])));
                }
                else if (i == nuPointsMinus)
                {
                    perpVector = CCPointExtension.ccpPerp(CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(points[i - 1], p1)));
                }
                else
                {
                    CCPoint p2 = points[i + 1];
                    CCPoint p0 = points[i - 1];

                    CCPoint p2p1 = CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(p2, p1));
                    CCPoint p0p1 = CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(p0, p1));

                    // Calculate angle between vectors
                    float angle = (float)Math.Acos(CCPointExtension.ccpDot(p2p1, p0p1));

                    if (angle < ccMacros.CC_DEGREES_TO_RADIANS(70))
                    {
                        perpVector = CCPointExtension.ccpPerp(CCPointExtension.ccpNormalize(CCPointExtension.ccpMidpoint(p2p1, p0p1)));
                    }
                    else if (angle < ccMacros.CC_DEGREES_TO_RADIANS(170))
                    {
                        perpVector = CCPointExtension.ccpNormalize(CCPointExtension.ccpMidpoint(p2p1, p0p1));
                    }
                    else
                    {
                        perpVector = CCPointExtension.ccpPerp(CCPointExtension.ccpNormalize(CCPointExtension.ccpSub(p2, p0)));
                    }
                }
                perpVector = CCPointExtension.ccpMult(perpVector, stroke);

                vertices[idx]     = new ccVertex2F(p1.x + perpVector.x, p1.y + perpVector.y);
                vertices[idx + 1] = new ccVertex2F(p1.x - perpVector.x, p1.y - perpVector.y);
            }

            // Validate vertexes
            offset = (offset == 0) ? 0 : (offset - 1);
            for (int i = offset; i < nuPointsMinus; i++)
            {
                idx = i * 2;
                int idx1 = idx + 2;

                ccVertex2F p1 = vertices[idx];
                ccVertex2F p2 = vertices[idx + 1];
                ccVertex2F p3 = vertices[idx1];
                ccVertex2F p4 = vertices[idx1 + 1];

                float s = 0f;
                //BOOL fixVertex = !ccpLineIntersect(ccp(p1.x, p1.y), ccp(p4.x, p4.y), ccp(p2.x, p2.y), ccp(p3.x, p3.y), &s, &t);
                bool fixVertex = !LineIntersect(p1.x, p1.y, p4.x, p4.y, p2.x, p2.y, p3.x, p3.y, out s);
                if (!fixVertex)
                {
                    if (s < 0.0f || s > 1.0f)
                    {
                        fixVertex = true;
                    }
                }

                if (fixVertex)
                {
                    vertices[idx1]     = p4;
                    vertices[idx1 + 1] = p3;
                }
            }
        }
Example #55
0
        public static void ccDrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoint destination, int segments, ccColor4F color)
        {
            VertexPositionColor[] vector3    = new VertexPositionColor[segments + 1];
            float         contentScaleFactor = CCDirector.sharedDirector().ContentScaleFactor;
            CCApplication cCApplication      = CCApplication.sharedApplication();
            float         single             = 0f;

            for (int i = 0; i < segments; i++)
            {
                float single1 = (float)Math.Pow((double)(1f - single), 3) * origin.x + 3f * (float)Math.Pow((double)(1f - single), 2) * single * control1.x + 3f * (1f - single) * single * single * control2.x + single * single * single * destination.x;
                float single2 = (float)Math.Pow((double)(1f - single), 3) * origin.y + 3f * (float)Math.Pow((double)(1f - single), 2) * single * control1.y + 3f * (1f - single) * single * single * control2.y + single * single * single * destination.y;
                vector3[i]          = new VertexPositionColor();
                vector3[i].Position = new Vector3(single1 * contentScaleFactor, single2 * contentScaleFactor, 0f);
                vector3[i].Color    = new Color(color.r, color.g, color.b, color.a);
                single = single + 1f / (float)segments;
            }
            VertexPositionColor vertexPositionColor = new VertexPositionColor()
            {
                Color    = new Color(color.r, color.g, color.b, color.a),
                Position = new Vector3(destination.x * contentScaleFactor, destination.y * contentScaleFactor, 0f)
            };

            vector3[segments] = vertexPositionColor;
            cCApplication.basicEffect.TextureEnabled     = false;
            cCApplication.basicEffect.VertexColorEnabled = true;
            foreach (EffectPass pass in cCApplication.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                cCApplication.GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineStrip, vector3, 0, segments);
            }
        }
Example #56
0
 public virtual void updatePosition(CCPoint newPos)
 {
     Target.Position = newPos + m_startPosition;
 }
Example #57
0
 /// <summary>
 /// set center position
 /// </summary>
 public void setPosition(CCPoint position)
 {
     m_position           = position;
     m_positionInPixels.X = position.X * Director.SharedDirector.ContentScaleFactor;
     m_positionInPixels.Y = position.Y * Director.SharedDirector.ContentScaleFactor;
 }
Example #58
0
 public CCTouch(int nViewId, float x, float y)
 {
     this.m_nViewId   = nViewId;
     this.m_point     = new CCPoint(x, y);
     this.m_prevPoint = new CCPoint(x, y);
 }
Example #59
0
 public CCPlace()
 {
     m_tPosition = new CCPoint();
 }
 public virtual new void updatePosition(CCPoint newPos)
 {
     this.m_pTarget.position = newPos.Add(this.m_startPosition);
 }