本文整理汇总了C#中CocosSharp.CCSprite类的典型用法代码示例。如果您正苦于以下问题:C# CCSprite类的具体用法?C# CCSprite怎么用?C# CCSprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCSprite类属于CocosSharp命名空间,在下文中一共展示了CCSprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IntroLayer
public IntroLayer()
: base(CCColor4B.Gray)
{
titleLabel = new CCLabel("CocosJuce", "fonts/Roboto-Light-72.fnt");
frequencyLabel = new CCLabel("", "fonts/Roboto-Light-72.fnt");
onOffSwitchSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
onOffSwitchSpriteFrameCache.AddSpriteFrames("images/onoffswitch.plist");
switchOnSprite = new CCSprite("switch_on.png");
switchOffSprite = new CCSprite("switch_off.png");
onOffSwitch = new CCMenuItemToggle(SwitchToggle, new CCMenuItem[]
{
new CCMenuItemImage(switchOffSprite) { },
new CCMenuItemImage(switchOnSprite) { },
});
menu = new CCMenu(onOffSwitch);
freqKnobSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
freqKnobSpriteFrameCache.AddSpriteFrames("images/frequencyknob.plist");
frequencyKnob = new CCSprite("frequencyknob00.png");
AddChild(titleLabel);
AddChild(menu);
AddChild(frequencyLabel);
AddChild(frequencyKnob);
}
示例2: StartScene
public StartScene(CCWindow mainWindow)
: base(mainWindow)
{
mainLayer = new CCLayer ();
AddChild (mainLayer);
PlayButton = new CCSprite ("logo");
NameLabel = new CCLabel ("Map Knight - Alpha", "arial", 22);
CreatorLabel = new CCLabel ("Created by tipfom and Exo", "arial", 22);
VersionLabel = new CCLabel ("Version unspecified", "arial", 22);
InfoLabel = new CCLabel ("Click to play", "arial", 22);
PlayButton.ScaleX = mainWindow.WindowSizeInPixels.Width / PlayButton.ContentSize.Width;
PlayButton.ScaleY = mainWindow.WindowSizeInPixels.Height / PlayButton.ContentSize.Height;
PlayButton.Position = new CCPoint (PlayButton.ScaledContentSize.Width / 2, PlayButton.ScaledContentSize.Height / 2);
NameLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, mainWindow.WindowSizeInPixels.Height / 2 - NameLabel.ContentSize.Height);
CreatorLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, NameLabel.PositionY - CreatorLabel.ContentSize.Height - 30);
VersionLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, CreatorLabel.PositionY - VersionLabel.ContentSize.Height - 30);
InfoLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, VersionLabel.PositionY - InfoLabel.ContentSize.Height - 30);
mainLayer.AddChild (PlayButton);
mainLayer.AddChild (NameLabel);
mainLayer.AddChild (CreatorLabel);
mainLayer.AddChild (VersionLabel);
mainLayer.AddChild (InfoLabel);
touchListener = new CCEventListenerTouchAllAtOnce ();
touchListener.OnTouchesEnded = HandleTouchesEnded;
AddEventListener (touchListener, this);
}
示例3: PopUpLayer
public PopUpLayer(CCSprite background, CCLabel title)
{
mBackgroundImage = background;
mTitle = title;
CreateLayer ();
}
示例4: SpriteWithColor
public SpriteWithColor(CCColor4B bgColor, CCSize textureSizeInPixels) : base ()
{
// 1: Create new CCRenderTexture
CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);
// 2: Call CCRenderTexture:begin
rt.BeginWithClear(bgColor);
// 3: Draw into the texture
// You'll add this later
GenerateGradient(textureSizeInPixels);
var noise = new CCSprite("images/Noise.png");
noise.AnchorPoint = CCPoint.AnchorLowerLeft;
noise.Position = CCPoint.Zero;
noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
noise.Texture.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.LinearWrap;
// To get the linear wrap to work correctly we have to set the TextureRectInPixels as well as ContentSize
noise.TextureRectInPixels = new CCRect(0, 0, textureSizeInPixels.Width, textureSizeInPixels.Height);
noise.ContentSize = noise.TextureRectInPixels.Size;
noise.Visit();
// 4: Call CCRenderTexture:end
rt.End();
this.Texture = rt.Texture;
}
示例5: SpriteOffsetAnchorRotation
public SpriteOffsetAnchorRotation()
{
sprites = new CCSprite[numOfSprites];
pointSprites = new CCSprite[numOfSprites];
// Create actions
CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;
cache.AddSpriteFrames("animations/grossini.plist");
cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray");
var animFrames = new List<CCSpriteFrame>();
string tmp = "";
for (int j = 0; j < 14; j++)
{
tmp = string.Format("grossini_dance_{0:00}.png", j + 1);
CCSpriteFrame frame = cache[tmp];
animFrames.Add(frame);
}
animation = new CCAnimation(animFrames, 0.3f);
for (int i = 0; i < numOfSprites; i++)
{
// Animation using Sprite batch
sprites[i] = new CCSprite("grossini_dance_01.png");
AddChild(sprites[i], 0);
pointSprites[i] = new CCSprite("Images/r1");
AddChild(pointSprites[i], 1);
}
}
示例6: GameLayer
public GameLayer ()
{
var touchListener = new CCEventListenerTouchAllAtOnce();
touchListener.OnTouchesEnded = OnTouchesEnded;
EventDispatcher.AddEventListener(touchListener, this);
Color = new CCColor3B (CCColor4B.White);
Opacity = 255;
visibleBananas = new List<CCSprite> ();
hitBananas = new List<CCSprite> ();
monkey = new CCSprite ("Monkey");
monkey.Position = CCDirector.SharedDirector.WinSize.Center;
AddChild (monkey);
Schedule ((t) => {
visibleBananas.Add (AddBanana ());
dt += t;
if(ShouldEndGame ()){
var gameOverScene = GameOverLayer.SceneWithScore(hitBananas.Count);
CCTransitionFadeDown transitionToGameOver = new CCTransitionFadeDown(1.0f, gameOverScene);
CCDirector.SharedDirector.ReplaceScene (transitionToGameOver);
}
}, 1.0f);
Schedule ((t) => {
CheckCollision ();
});
}
示例7: SpriteChildrenVisibilityIssue665
public SpriteChildrenVisibilityIssue665()
{
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");
aParent = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(aParent, 0);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite2 = new CCSprite("grossini_dance_02.png");
sprite3 = new CCSprite("grossini_dance_03.png");
// test issue #665
sprite1.Visible = false;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, 2);
aParent2 = new CCNode();
AddChild(aParent2, 0);
sprite4 = new CCSprite("grossini_dance_01.png");
sprite5 = new CCSprite("grossini_dance_02.png");
sprite6 = new CCSprite("grossini_dance_03.png");
// test issue #665
sprite4.Visible = false;
aParent2.AddChild(sprite4);
sprite4.AddChild(sprite5, -2);
sprite4.AddChild(sprite6, 2);
}
示例8: GameLayer
public GameLayer()
: base(CCColor4B.Blue, CCColor4B.AliceBlue)
{
// Set the layer gradient direction
this.Vector = new CCPoint(0.5f, 0.5f);
// Create and add sprites
monkeySprite1 = new CCSprite("monkey");
AddChild(monkeySprite1, 1);
monkeySprite2 = new CCSprite("monkey");
AddChild(monkeySprite2, 1);
// Define actions
var moveUp = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f));
var moveDown = moveUp.Reverse();
// A CCSequence action runs the list of actions in ... sequence!
CCSequence moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown));
repeatedAction = new CCRepeatForever(moveSeq);
// A CCSpawn action runs the list of actions concurrently
dreamAction = new CCSpawn(new CCFadeIn(5.0f), new CCWaves(5.0f, new CCGridSize(10, 20), 4, 4));
// Schedule for method to be called every 0.1s
Schedule(UpdateLayerGradient, 0.1f);
}
示例9: TextLayer
public TextLayer() : base()
{
Camera = AppDelegate.SharedCamera;
contentLayer = new CCLayer();
CCCamera contentCamera = new CCCamera(Camera.OrthographicViewSizeWorldspace, Camera.CenterInWorldspace, Camera.TargetInWorldspace);
contentLayer.Camera = contentCamera;
var bg = new CCSprite(TestResource.s_back3);
BaseNode = bg;
contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);
var Kathia = new CCSprite(TestResource.s_pPathSister2);
BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);
var sc = new CCScaleBy(2, 5);
var sc_back = sc.Reverse();
Kathia.RunAction(new CCRepeatForever(sc, sc_back));
var Tamara = new CCSprite(TestResource.s_pPathSister1);
BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);
var sc2 = new CCScaleBy(2, 5);
var sc2_back = sc2.Reverse();
Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
contentLayer.AddChild(colorBackground, -1);
}
示例10: Test6
public Test6()
{
CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1);
CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2);
CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2);
sp1.Position = (new CCPoint(100, 160));
sp2.Position = (new CCPoint(380, 160));
CCFiniteTimeAction rot = new CCRotateBy (2, 360);
var rot_back = rot.Reverse();
var forever1 = new CCRepeatForever (rot, rot_back);
AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
sp1.AddChild(sp11);
AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
sp2.AddChild(sp21);
sp1.RunAction(forever1);
sp11.RunAction(forever1);
sp2.RunAction(forever1);
sp21.RunAction(forever1);
Schedule(addAndRemove, 2.0f);
}
示例11: Test5
public Test5()
{
CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
sp2 = new CCSprite(TestResource.s_pPathSister2);
sp1.Position = (new CCPoint(100, 160));
sp2.Position = (new CCPoint(380, 160));
var rot = new CCRotateBy (2, 360);
var rot_back = rot.Reverse();
var forever = new CCRepeatForever (rot, rot_back) { Tag = 101 };
// Since Actions are immutable to set the tag differently we need to
// create a new action. Notice that the same actions can be used in
// this case instead of copying them as well.
forever2 = new CCRepeatForever (rot, rot_back) { Tag = 102 };
AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
RemoveChild(sp2, true);
AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
// Sprite 1 should run and run
// Sprite 2 should stop
sp1.RunAction(forever);
sp2.RunAction(forever2);
// Experiment with removing sp2 and re-adding it after cleanup to reproduce an error in child management
//ScheduleOnce(Stage2OfTest, 2.0f);
Schedule(addAndRemove, 2.0f);
}
示例12: TextLayer
public TextLayer() : base()
{
Color = new CCColor3B(32, 128, 32);
Opacity = 255;
BaseNode = new CCNodeGrid();
var effect = CurrentAction;
BaseNode.RunAction(effect);
AddChild(BaseNode, 0, EffectTestScene.kTagBackground);
var bg = new CCSprite(TestResource.s_back3);
BaseNode.AddChild(bg, 0);
var Kathia = new CCSprite(TestResource.s_pPathSister2);
BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);
var sc = new CCScaleBy(2, 5);
var sc_back = sc.Reverse();
Kathia.RunAction(new CCRepeatForever(sc, sc_back));
var Tamara = new CCSprite(TestResource.s_pPathSister1);
BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);
var sc2 = new CCScaleBy(2, 5);
var sc2_back = sc2.Reverse();
Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
}
示例13: SpriteZVertex
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.
//
dir = 1;
time = 0;
sprites = new CCSprite[numOfSprites];
node = new CCNode();
AddChild(node, 0);
for (int i = 0; i < 5; i++)
{
CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
node.AddChild(sprite, 0);
sprites[i] = sprite;
}
for (int i = 5; i < 11; i++)
{
CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
node.AddChild(sprite, 0);
sprites[i] = sprite;
}
}
示例14: TextLayer
public TextLayer() : base()
{
contentLayer = new CCLayer();
CCCamera contentCamera = Camera;
contentLayer.Camera = contentCamera;
var bg = new CCSprite(TestResource.s_back3);
BaseNode = bg;
contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);
var Kathia = new CCSprite(TestResource.s_pPathSister2);
BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);
var sc = new CCScaleBy(2, 5);
var sc_back = sc.Reverse();
Kathia.RunAction(new CCRepeatForever(sc, sc_back));
var Tamara = new CCSprite(TestResource.s_pPathSister1);
BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);
var sc2 = new CCScaleBy(2, 5);
var sc2_back = sc2.Reverse();
Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
contentLayer.AddChild(colorBackground, -1);
}
示例15: AddNewSpriteWithCoords
void AddNewSpriteWithCoords(CCPoint p)
{
CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);
int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
int x = (idx % 5) * 85;
int y = (idx / 5) * 121;
CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121));
sprite.Position = (new CCPoint(p.X, p.Y));
BatchNode.AddChild(sprite);
CCFiniteTimeAction action = null;
float random = (float)CCRandom.NextDouble();
if (random < 0.20)
action = new CCScaleBy(3, 2);
else if (random < 0.40)
action = new CCRotateBy (3, 360);
else if (random < 0.60)
action = new CCBlink (1, 3);
else if (random < 0.8)
action = new CCTintBy (2, 0, -255, -255);
else
action = new CCFadeOut (2);
CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back));
sprite.RunAction(new CCRepeatForever (seq));
}