Ejemplo n.º 1
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test2");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

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


            CCTMXLayer layer = map.layerNamed("Layer 0");

            layer.Texture.setAntiAliasTexParameters();

            map.scale = 1;

            CCSprite tile0 = layer.tileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.tileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.tileAt(new CCPoint(3, 62));//ccp(1,62));
            CCSprite tile3 = layer.tileAt(new CCPoint(2, 62));

            tile0.anchorPoint = new CCPoint(0.5f, 0.5f);
            tile1.anchorPoint = new CCPoint(0.5f, 0.5f);
            tile2.anchorPoint = new CCPoint(0.5f, 0.5f);
            tile3.anchorPoint = new CCPoint(0.5f, 0.5f);

            CCActionInterval   move      = CCMoveBy.actionWithDuration(0.5f, new CCPoint(0, 160));
            CCActionInterval   rotate    = CCRotateBy.actionWithDuration(2, 360);
            CCActionInterval   scale     = CCScaleBy.actionWithDuration(2, 5);
            CCActionInterval   opacity   = CCFadeOut.actionWithDuration(2);
            CCActionInterval   fadein    = CCFadeIn.actionWithDuration(2);
            CCActionInterval   scaleback = CCScaleTo.actionWithDuration(1, 1);
            CCActionInstant    finish    = CCCallFuncN.actionWithTarget(this, removeSprite);
            CCFiniteTimeAction seq0      = CCSequence.actions(move, rotate, scale, opacity, fadein, scaleback, finish);
            CCActionInterval   seq1      = (CCActionInterval)(seq0.copy());
            CCActionInterval   seq2      = (CCActionInterval)(seq0.copy());
            CCActionInterval   seq3      = (CCActionInterval)(seq0.copy());

            tile0.runAction(seq0);
            tile1.runAction(seq1);
            tile2.runAction(seq2);
            tile3.runAction(seq3);


            m_gid = layer.tileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

            schedule(updateCol, 2.0f);
            schedule(repaintWithGID, 2.0f);
            schedule(removeTiles, 1.0f);

            ////----UXLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads());
            ////----UXLOG("++++children: %d", layer->getChildren()->count() );

            m_gid2 = 0;
        }
Ejemplo n.º 2
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(3);

            CCActionInterval   actionTo     = CCScaleTo.actionWithDuration(2, 0.5f);
            CCActionInterval   actionBy     = CCScaleBy.actionWithDuration(2, 2);
            CCActionInterval   actionBy2    = CCScaleBy.actionWithDuration(2, 0.25f, 4.5f);
            CCFiniteTimeAction actionByBack = actionBy.reverse();

            m_tamara.runAction(actionTo);
            m_grossini.runAction(CCSequence.actions(actionBy, actionByBack));
            m_kathia.runAction(CCSequence.actions(actionBy2, actionBy2.reverse()));
        }
Ejemplo n.º 3
0
        public override void onEnter()
        {
            // todo: CCLayerColor hasn't been implemented

            base.onEnter();

            m_tamara.removeFromParentAndCleanup(true);
            m_grossini.removeFromParentAndCleanup(true);
            m_kathia.removeFromParentAndCleanup(true);

            CCSize boxSize = new CCSize(100.0f, 100.0f);

            CCLayerColor box = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 0, 255));

            box.anchorPoint = new CCPoint(0, 0);
            box.position    = new CCPoint(190, 110);
            box.contentSize = boxSize;

            CCLayerColor uL = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 0, 255));

            box.addChild(uL);
            uL.contentSize = new CCSize(markrside, markrside);
            uL.position    = new CCPoint(0.0f, boxSize.height - markrside);
            uL.anchorPoint = new CCPoint(0, 0);

            CCLayerColor uR = CCLayerColor.layerWithColor(new ccColor4B(0, 0, 255, 255));

            box.addChild(uR);
            uR.contentSize = new CCSize(markrside, markrside);
            uR.position    = new CCPoint(boxSize.width - markrside, boxSize.height - markrside);
            uR.anchorPoint = new CCPoint(0, 0);
            addChild(box);

            CCActionInterval actionTo      = CCSkewTo.actionWithDuration(2, 0.0f, 2.0f);
            CCActionInterval rotateTo      = CCRotateTo.actionWithDuration(2, 61.0f);
            CCActionInterval actionScaleTo = CCScaleTo.actionWithDuration(2, -0.44f, 0.47f);

            CCActionInterval actionScaleToBack = CCScaleTo.actionWithDuration(2, 1.0f, 1.0f);
            CCActionInterval rotateToBack      = CCRotateTo.actionWithDuration(2, 0);
            CCActionInterval actionToBack      = CCSkewTo.actionWithDuration(2, 0, 0);

            box.runAction(CCSequence.actions(actionTo, actionToBack));
            box.runAction(CCSequence.actions(rotateTo, rotateToBack));
            box.runAction(CCSequence.actions(actionScaleTo, actionScaleToBack));
        }
Ejemplo n.º 4
0
        public override void onEnter()
        {
            base.onEnter();

            this.isTouchEnabled = true;

            CCSize       s     = CCDirector.sharedDirector().getWinSize();
            CCLayerColor layer = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0xFF, 0x00, 0x00, 0x80), s.width * 0.75f, s.height * 0.75f);

            layer.isRelativeAnchorPoint = true;
            layer.position = (new CCPoint(s.width / 2, s.height / 2));
            addChild(layer, 1, kTagLayer);
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = CCLabelBMFont.labelWithString("LABEL1", "fonts/fnt/konqa32");

            layer.addChild(label1);
            label1.position = new CCPoint(layer.contentSize.width / 2, layer.contentSize.height * 0.75f);
            CCLabelBMFont label2 = CCLabelBMFont.labelWithString("LABEL2", "fonts/fnt/konqa32");

            layer.addChild(label2);
            label2.position = new CCPoint(layer.contentSize.width / 2, layer.contentSize.height * 0.25f);
            //
            // Do the sequence of actions in the bug report
            float waitTime = 3f;
            float runTime  = 12f;

            layer.visible = false;
            CCHide      hide     = CCHide.action();
            CCScaleTo   scaleTo1 = CCScaleTo.actionWithDuration(0.0f, 0.0f);
            CCShow      show     = CCShow.action();
            CCDelayTime delay    = CCDelayTime.actionWithDuration(waitTime);
            CCScaleTo   scaleTo2 = CCScaleTo.actionWithDuration(runTime * 0.25f, 1.2f);
            CCScaleTo   scaleTo3 = CCScaleTo.actionWithDuration(runTime * 0.25f, 0.95f);
            CCScaleTo   scaleTo4 = CCScaleTo.actionWithDuration(runTime * 0.25f, 1.1f);
            CCScaleTo   scaleTo5 = CCScaleTo.actionWithDuration(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = CCSequence.actions(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5);

            layer.runAction(seq);
        }
Ejemplo n.º 5
0
 public void bugMe(CCNode node)
 {
     node.stopAllActions(); //After this stop next action not working, if remove this stop everything is working
     node.runAction(CCScaleTo.actionWithDuration(2, 2));
 }
Ejemplo n.º 6
0
        public SpriteBatchNodeChildren2()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // parents
            CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini", 50);

            batch.Texture.generateMipmap();

            addChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini");


            CCSprite sprite11 = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");

            sprite11.position = (new CCPoint(s.width / 3, s.height / 2));

            CCSprite sprite12 = CCSprite.spriteWithSpriteFrameName("grossini_dance_02.png");

            sprite12.position = (new CCPoint(20, 30));
            sprite12.scale    = 0.2f;

            CCSprite sprite13 = CCSprite.spriteWithSpriteFrameName("grossini_dance_03.png");

            sprite13.position = (new CCPoint(-20, 30));
            sprite13.scale    = 0.2f;

            batch.addChild(sprite11);
            sprite11.addChild(sprite12, -2);
            sprite11.addChild(sprite13, 2);

            // don't rotate with it's parent
            sprite12.honorParentTransform = ((ccHonorParentTransform)(sprite12.honorParentTransform & ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_TRANSLATE));

            // don't scale and rotate with it's parent
            sprite13.honorParentTransform = ((ccHonorParentTransform)(sprite13.honorParentTransform & (ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_SCALE | ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_ROTATE)));

            CCActionInterval action        = CCMoveBy.actionWithDuration(2, new CCPoint(200, 0));
            CCActionInterval action_back   = (CCActionInterval)action.reverse();
            CCActionInterval action_rot    = CCRotateBy.actionWithDuration(2, 360);
            CCActionInterval action_s      = CCScaleBy.actionWithDuration(2, 2);
            CCActionInterval action_s_back = (CCActionInterval)action_s.reverse();

            sprite11.runAction(CCRepeatForever.actionWithAction(action_rot));
            sprite11.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action, action_back))));
            sprite11.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action_s, action_s_back))));

            //
            // another set of parent / children
            //

            CCSprite sprite21 = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");

            sprite21.position = (new CCPoint(2 * s.width / 3, s.height / 2 - 50));

            CCSprite sprite22 = CCSprite.spriteWithSpriteFrameName("grossini_dance_02.png");

            sprite22.position = (new CCPoint(20, 30));
            sprite22.scale    = 0.8f;

            CCSprite sprite23 = CCSprite.spriteWithSpriteFrameName("grossini_dance_03.png");

            sprite23.position = (new CCPoint(-20, 30));
            sprite23.scale    = 0.8f;

            batch.addChild(sprite21);
            sprite21.addChild(sprite22, -2);
            sprite21.addChild(sprite23, 2);

            // don't rotate with it's parent
            sprite22.honorParentTransform = ((ccHonorParentTransform)(sprite22.honorParentTransform & ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_TRANSLATE));

            // don't scale and rotate with it's parent
            sprite23.honorParentTransform = ((ccHonorParentTransform)(sprite23.honorParentTransform & ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_SCALE));

            sprite21.runAction(CCRepeatForever.actionWithAction(CCRotateBy.actionWithDuration(1, 360)));
            sprite21.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(CCScaleTo.actionWithDuration(0.5f, 5.0f), CCScaleTo.actionWithDuration(0.5f, 1)))));
        }