public SpriteNilTexture() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCSprite sprite = null; // TEST: If no texture is given, then Opacity + Color should work. sprite = new CCSprite(); sprite.init(); sprite.setTextureRect(new CCRect(0, 0, 300, 300)); sprite.Color = new ccColor3B(Color.Red); sprite.Opacity = 128; sprite.position = (new CCPoint(3 * s.width / 4, s.height / 2)); addChild(sprite, 100); sprite = new CCSprite(); sprite.init(); sprite.setTextureRect(new CCRect(0, 0, 300, 300)); sprite.Color = new ccColor3B(Color.Blue); sprite.Opacity = 128 ; sprite.position = (new CCPoint(1 * s.width / 4, s.height / 2)); addChild(sprite, 100); }
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)); }
public AnimationCache() { CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini"); CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini_gray"); CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini_blue"); // // create animation "dance" // List<CCSpriteFrame> animFrames = new List<CCSpriteFrame>(15); string str = ""; for (int i = 1; i < 15; i++) { string temp = ""; if (i<10) { temp = "0" + i; } else { temp = i.ToString(); } str = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str); animFrames.Add(frame); } CCAnimation animation = CCAnimation.animationWithFrames(animFrames, 0.2f); // Add an animation to the Cache CCAnimationCache.sharedAnimationCache().addAnimation(animation, "dance"); // // create animation "dance gray" // animFrames.Clear(); for (int i = 1; i < 15; i++) { string temp = ""; if (i < 10) { temp = "0" + i; } else { temp = i.ToString(); } str = String.Format("grossini_dance_gray_{0}.png", temp); CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str); animFrames.Add(frame); } animation = CCAnimation.animationWithFrames(animFrames, 0.2f); // Add an animation to the Cache CCAnimationCache.sharedAnimationCache().addAnimation(animation, "dance_gray"); // // create animation "dance blue" // animFrames.Clear(); for (int i = 1; i < 4; i++) { str = String.Format("grossini_blue_0{0}.png", i); CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str); animFrames.Add(frame); } animation = CCAnimation.animationWithFrames(animFrames, 0.2f); // Add an animation to the Cache CCAnimationCache.sharedAnimationCache().addAnimation(animation, "dance_blue"); CCAnimationCache animCache = CCAnimationCache.sharedAnimationCache(); CCAnimation normal = animCache.animationByName("dance"); CCAnimation dance_grey = animCache.animationByName("dance_gray"); CCAnimation dance_blue = animCache.animationByName("dance_blue"); CCAnimate animN = CCAnimate.actionWithAnimation(normal); CCAnimate animG = CCAnimate.actionWithAnimation(dance_grey); CCAnimate animB = CCAnimate.actionWithAnimation(dance_blue); CCFiniteTimeAction seq = CCSequence.actions(animN, animG, animB); // create an sprite without texture CCSprite grossini = new CCSprite(); grossini.init(); CCSize winSize = CCDirector.sharedDirector().getWinSize(); grossini.position = (new CCPoint(winSize.width / 2, winSize.height / 2)); addChild(grossini); // run the animation grossini.runAction(seq); }