public CameraOrbitTest() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCSprite p = CCSprite.spriteWithFile(TestResource.s_back3); addChild(p, 0); p.position = (new CCPoint(s.width / 2, s.height / 2)); p.Opacity = 128; CCSprite sprite; CCOrbitCamera orbit; CCCamera cam; CCSize ss; // LEFT s = p.contentSize; sprite = CCSprite.spriteWithFile(TestResource.s_pPathGrossini); sprite.scale = (0.5f); p.addChild(sprite, 0); sprite.position = (new CCPoint(s.width / 4 * 1, s.height / 2)); cam = sprite.Camera; orbit = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 360, 0, 0); //sprite.runAction(CCRepeatForever.actionWithAction(orbit)); // CENTER sprite = CCSprite.spriteWithFile(TestResource.s_pPathGrossini); sprite.scale = 1.0f; p.addChild(sprite, 0); sprite.position = new CCPoint(s.width / 4 * 2, s.height / 2); orbit = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 360, 45, 0); //sprite.runAction(CCRepeatForever.actionWithAction(orbit)); // RIGHT sprite = CCSprite.spriteWithFile(TestResource.s_pPathGrossini); sprite.scale = 2.0f; p.addChild(sprite, 0); sprite.position = new CCPoint(s.width / 4 * 3, s.height / 2); ss = sprite.contentSize; orbit = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 360, 90, -45); //sprite.runAction(CCRepeatForever.actionWithAction(orbit)); // PARENT orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 90); //p.runAction(CCRepeatForever.actionWithAction(orbit)); scale = 1; }
public SpriteBatchNodeZVertex() { // // This test tests z-order // If you are going to use it is better to use a 3D projection // // WARNING: // The developer is resposible for ordering it's sprites according to it's Z if the sprite has // transparent parts. // CCSize s = CCDirector.sharedDirector().getWinSize(); float step = s.width / 12; // small capacity. Testing resizing. // Don't use capacity=1 in your real game. It is expensive to resize the capacity CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 1); // camera uses the center of the image as the pivoting point batch.contentSize = new CCSize(s.width, s.height); batch.anchorPoint = (new CCPoint(0.5f, 0.5f)); batch.position = (new CCPoint(s.width / 2, s.height / 2)); addChild(batch, 0, (int)kTags.kTagSpriteBatchNode); for (int i = 0; i < 5; i++) { CCSprite sprite = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121)); sprite.position = (new CCPoint((i + 1) * step, s.height / 2)); sprite.vertexZ = (10 + i * 40); batch.addChild(sprite, 0); } for (int i = 5; i < 11; i++) { CCSprite sprite = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * 1, 121 * 0, 85, 121)); sprite.position = (new CCPoint((i + 1) * step, s.height / 2)); sprite.vertexZ = 10 + (10 - i) * 40; batch.addChild(sprite, 0); } batch.runAction(CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0)); }
public SpriteZVertex() { // // This test tests z-order // If you are going to use it is better to use a 3D projection // // WARNING: // The developer is resposible for ordering it's sprites according to it's Z if the sprite has // transparent parts. // m_dir = 1; m_time = 0; CCSize s = CCDirector.sharedDirector().getWinSize(); float step = s.width / 12; CCNode node = CCNode.node(); // camera uses the center of the image as the pivoting point node.contentSize = (new CCSize(s.width, s.height)); node.anchorPoint = (new CCPoint(0.5f, 0.5f)); node.position = (new CCPoint(s.width / 2, s.height / 2)); addChild(node, 0); for (int i = 0; i < 5; i++) { CCSprite sprite = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); sprite.position = (new CCPoint((i + 1) * step, s.height / 2)); sprite.vertexZ = (10 + i * 40); node.addChild(sprite, 0); } for (int i = 5; i < 11; i++) { CCSprite sprite = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121)); sprite.position = (new CCPoint((i + 1) * step, s.height / 2)); sprite.vertexZ = 10 + (10 - i) * 40; node.addChild(sprite, 0); } node.runAction(CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0)); }
public override void onEnter() { base.onEnter(); CCNode target = getChildByTag(EffectAdvanceScene.kTagBackground); // To reuse a grid the grid size and the grid type must be the same. // in this case: // Lens3D is Grid3D and it's size is (15,10) // Waves3D is Grid3D and it's size is (15,10) CCSize size = CCDirector.sharedDirector().getWinSize(); CCActionInterval lens = CCLens3D.actionWithPosition(new CCPoint(size.width / 2, size.height / 2), 240, new ccGridSize(15, 10), 0.0f); CCActionInterval waves = CCWaves3D.actionWithWaves(18, 15, new ccGridSize(15, 10), 10); CCFiniteTimeAction reuse = CCReuseGrid.actionWithTimes(1); CCActionInterval delay = CCDelayTime.actionWithDuration(8); CCActionInterval orbit = CCOrbitCamera.actionWithDuration(5, 1, 2, 0, 180, 0, -90); CCFiniteTimeAction orbit_back = orbit.reverse(); target.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(orbit, orbit_back)))); target.runAction(CCSequence.actions(lens, delay, reuse, waves)); }
public override void onEnter() { // todo : CCOrbitCamera hasn't been implement base.onEnter(); centerSprites(3); CCOrbitCamera orbit1 = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 180, 0, 0); CCFiniteTimeAction action1 = CCSequence.actions( orbit1, orbit1.reverse()); CCOrbitCamera orbit2 = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 180, -45, 0); CCFiniteTimeAction action2 = CCSequence.actions( orbit2, orbit2.reverse()); CCOrbitCamera orbit3 = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 180, 90, 0); CCFiniteTimeAction action3 = CCSequence.actions( orbit3, orbit3.reverse()); m_kathia.runAction(CCRepeatForever.actionWithAction((CCActionInterval)action1)); m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)action2)); m_grossini.runAction(CCRepeatForever.actionWithAction((CCActionInterval)action3)); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(100, -100)); CCFiniteTimeAction move_back = move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); CCAction rfe = CCRepeatForever.actionWithAction((CCActionInterval)seq); m_kathia.runAction(rfe); m_tamara.runAction((CCAction)(rfe.copy())); m_grossini.runAction((CCAction)(rfe.copy())); }
public CameraCenterTest() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCSprite sprite; CCOrbitCamera orbit; // LEFT-TOP sprite = new CCSprite();//::node(); sprite.init(); addChild(sprite, 0); sprite.position = (new CCPoint(s.width / 5 * 1, s.height / 5 * 1)); sprite.Color = (new ccColor3B(Color.Red)); sprite.setTextureRect(new CCRect(0, 0, 120, 50)); orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0); //sprite.runAction(CCRepeatForever.actionWithAction( orbit)); // [sprite setAnchorPoint: CCPointMake(0,1)); // LEFT-BOTTOM sprite = new CCSprite();//::node(); sprite.init(); addChild(sprite, 0, 40); sprite.position = (new CCPoint(s.width / 5 * 1, s.height / 5 * 4)); sprite.Color = new ccColor3B(Color.Blue); sprite.setTextureRect(new CCRect(0, 0, 120, 50)); orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0); //sprite.runAction(CCRepeatForever.actionWithAction( orbit )); // [sprite setAnchorPoint: CCPointMake(0,0)); // RIGHT-TOP sprite = new CCSprite();//::node(); sprite.init(); addChild(sprite, 0); sprite.position = (new CCPoint(s.width / 5 * 4, s.height / 5 * 1)); sprite.Color = new ccColor3B(Color.Yellow); sprite.setTextureRect(new CCRect(0, 0, 120, 50)); orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0); //sprite.runAction(CCRepeatForever.actionWithAction(orbit)); // [sprite setAnchorPoint: CCPointMake(1,1)); // RIGHT-BOTTOM sprite = new CCSprite();//::node(); sprite.init(); addChild(sprite, 0, 40); sprite.position = (new CCPoint(s.width / 5 * 4, s.height / 5 * 4)); sprite.Color = new ccColor3B(Color.Green); sprite.setTextureRect(new CCRect(0, 0, 120, 50)); orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0); // sprite.runAction(CCRepeatForever.actionWithAction(orbit)); // [sprite setAnchorPoint: CCPointMake(1,0)); // CENTER sprite = new CCSprite(); sprite.init(); addChild(sprite, 0, 40); sprite.position = (new CCPoint(s.width / 2, s.height / 2)); sprite.Color = new ccColor3B(Color.White); sprite.setTextureRect(new CCRect(0, 0, 120, 50)); orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0); // sprite.runAction(CCRepeatForever.actionWithAction(orbit)); // [sprite setAnchorPoint: CCPointMake(0.5f, 0.5f)); }