示例#1
0
 //BOOL initWithTexture(CCTexture2D* aTexture);
 //virtual void setTexture(CCTexture2D* newTexture);
 public void move(float delta)
 {
     this.position =
         CCPointExtension.ccpAdd(position, CCPointExtension.ccpMult(m_velocity, delta));
     if (position.x > 320 - radius())
     {
         position      = new CCPoint(320 - radius(), position.y);
         m_velocity.x *= -1;
     }
     else if (position.x < radius())
     {
         position      = new CCPoint(radius(), position.y);
         m_velocity.x *= -1;
     }
 }
示例#2
0
        public int check_for_error(CCPoint p1, CCPoint p2, CCPoint p3, CCPoint p4, float s, float t)
        {
            //	the hit point is		p3 + t * (p4 - p3);
            //	the hit point also is	p1 + s * (p2 - p1);

            CCPoint p4_p3     = CCPointExtension.ccpSub(p4, p3);
            CCPoint p4_p3_t   = CCPointExtension.ccpMult(p4_p3, t);
            CCPoint hitPoint1 = CCPointExtension.ccpAdd(p3, p4_p3_t);

            CCPoint p2_p1     = CCPointExtension.ccpSub(p2, p1);
            CCPoint p2_p1_s   = CCPointExtension.ccpMult(p2_p1, s);
            CCPoint hitPoint2 = CCPointExtension.ccpAdd(p1, p2_p1_s);

            // Since float has rounding errors, only check if diff is < 0.05
            if ((Math.Abs(hitPoint1.x - hitPoint2.x) > 0.1f) || (Math.Abs(hitPoint1.y - hitPoint2.y) > 0.1f))
            {
                Debug.WriteLine("ERROR: (%f,%f) != (%f,%f)", hitPoint1.x, hitPoint1.y, hitPoint2.x, hitPoint2.y);
                return(1);
            }

            return(0);
        }
示例#3
0
        public TMXOrthoZorder()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test-zorder");

            base.addChild(map, 0, kTagTileMap);

            CCSize s = map.contentSize;

            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            m_tamara = CCSprite.spriteWithFile(TestResource.s_pPathSister1);
            map.addChild(m_tamara, map.children.Count);
            m_tamara.anchorPoint = new CCPoint(0.5f, 0);

            CCActionInterval   move = CCMoveBy.actionWithDuration(10, CCPointExtension.ccpMult(new CCPoint(400, 450), 1 / ccMacros.CC_CONTENT_SCALE_FACTOR()));
            CCFiniteTimeAction back = move.reverse();
            CCFiniteTimeAction seq  = CCSequence.actions(move, back);

            m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));


            schedule((this.repositionSprite));
        }
示例#4
0
        public TMXOrthoVertexZ()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test-vertexz");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
            // can use any CCSprite and it will work OK.
            CCTMXLayer layer = map.layerNamed("trees");

            m_tamara = layer.tileAt(new CCPoint(0, 11));
            CCLog.Log("{0} vertexZ: {1}", m_tamara, m_tamara.vertexZ);

            CCActionInterval   move = CCMoveBy.actionWithDuration(10, CCPointExtension.ccpMult(new CCPoint(400, 450), 1 / CCDirector.sharedDirector().ContentScaleFactor));
            CCFiniteTimeAction back = move.reverse();
            CCFiniteTimeAction seq  = CCSequence.actions(move, back);

            m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));

            schedule(repositionSprite);
        }