本文整理汇总了C#中cocos2d.CCSprite.init方法的典型用法代码示例。如果您正苦于以下问题:C# CCSprite.init方法的具体用法?C# CCSprite.init怎么用?C# CCSprite.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d.CCSprite
的用法示例。
在下文中一共展示了CCSprite.init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpriteNilTexture
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);
}
示例2: CameraCenterTest
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));
}
示例3: AnimationCache
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);
}