本文整理汇总了C#中CCNode类的典型用法代码示例。如果您正苦于以下问题:C# CCNode类的具体用法?C# CCNode怎么用?C# CCNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCNode类属于命名空间,在下文中一共展示了CCNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartWithTarget
public override void StartWithTarget(CCNode target)
{
base.StartWithTarget(target);
m_fStartAngle = target.Rotation;
if (m_fStartAngle > 0)
{
m_fStartAngle = m_fStartAngle % 350.0f;
}
else
{
m_fStartAngle = m_fStartAngle % -360.0f;
}
m_fDiffAngle = m_fDstAngle - m_fStartAngle;
if (m_fDiffAngle > 180)
{
m_fDiffAngle -= 360;
}
if (m_fDiffAngle < -180)
{
m_fDiffAngle += 360;
}
}
示例2: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;
// Defines an array of title to create buttons dynamically
var stringArray = new[] {
"Hello",
"Variable",
"Size",
"!"
};
CCNode layer = new CCNode ();
AddChild(layer, 1);
float total_width = 0, height = 0;
// For each title in the array
int i = 0;
foreach(var title in stringArray)
{
// Creates a button with this string as title
var button = standardButtonWithTitle(title);
if (i == 0)
{
button.Opacity = 50;
button.Color = new CCColor3B(0, 255, 0);
}
else if (i == 1)
{
button.Opacity = 200;
button.Color = new CCColor3B(0, 255, 0);
}
else if (i == 2)
{
button.Opacity = 100;
button.Color = new CCColor3B(0, 0, 255);
}
button.Position = new CCPoint (total_width + button.ContentSize.Width / 2, button.ContentSize.Height / 2);
layer.AddChild(button);
// Compute the size of the layer
height = button.ContentSize.Height;
total_width += button.ContentSize.Width;
i++;
}
layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
layer.ContentSize = new CCSize(total_width, height);
layer.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);
// Add the black background
var background = new CCScale9SpriteFile("extensions/buttonBackground");
background.ContentSize = new CCSize(total_width + 14, height + 14);
background.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);
AddChild(background);
}
示例3: StartWithTarget
protected internal override void StartWithTarget(CCNode target)
{
base.StartWithTarget(target);
m_sConfig.ControlPoint1 = (m_sConfig.ControlPoint1 - m_startPosition);
m_sConfig.ControlPoint2 = (m_sConfig.ControlPoint2 - m_startPosition);
m_sConfig.EndPosition = (m_sConfig.EndPosition - m_startPosition);
}
示例4: CCTileMap
public CCTileMap(CCTileMapInfo mapInfo)
: base(CCCameraProjection.Projection2D)
{
Type = mapInfo.MapType;
MapDimensions = mapInfo.MapDimensions;
MapInfo = mapInfo;
TileTexelSize = mapInfo.TileTexelSize;
ObjectGroups = mapInfo.ObjectGroups;
MapProperties = mapInfo.MapProperties;
TileProperties = mapInfo.TileProperties;
TileLayersContainer
= new CCNode(MapDimensions.Size * TileTexelSize * CCTileMapLayer.DefaultTexelToContentSizeRatios);
AddChild(TileLayersContainer);
int idx = 0;
List<CCTileLayerInfo> layers = mapInfo.Layers;
if (layers != null)
{
foreach (CCTileLayerInfo layerInfo in layers)
{
if (layerInfo.Visible)
{
CCTileSetInfo[] tilesets = TilesetsForLayer(layerInfo);
CCTileMapLayer child = new CCTileMapLayer(tilesets, layerInfo, mapInfo);
TileLayersContainer.AddChild(child, idx, idx);
idx++;
}
}
}
}
示例5: 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;
}
}
示例6: StressIt
async void StressIt (float dt)
{
if (this.NumberOfRunningActions > 0)
return;
var targetNode = new CCNodeGrid();
AddChild(targetNode);
//lbl = new CCSprite("images/bat2.png");
label1 = CreateLabel (string.Format("Score: {0:n0} - Level: {1}", 123456, count), 30, CCColor3B.Yellow, CCColor3B.Blue);
label1.Position = this.ContentSize.Center;
targetNode.AddChild(label1);
count++;
await targetNode.RunActionAsync(fadeOut);
// Make sure we unset our grid that was attached.
targetNode.Grid = null;
label1.RemoveFromParent();
label1 = null;
targetNode.RemoveFromParent();
// GC.Collect ();
// GC.WaitForPendingFinalizers ();
// GC.Collect ();
}
示例7: StartWithTarget
public override void StartWithTarget(CCNode target)
{
base.StartWithTarget(target);
m_sConfig.ControlPoint1 = CCPointExtension.Subtract(m_sConfig.ControlPoint1, m_startPosition);
m_sConfig.ControlPoint2 = CCPointExtension.Subtract(m_sConfig.ControlPoint2, m_startPosition);
m_sConfig.EndPosition = CCPointExtension.Subtract(m_sConfig.EndPosition, m_startPosition);
}
示例8: CreateLabel
public static CCNode CreateLabel(string text, float size, CCColor3B color, CCColor3B shadowColor)
{
var node = new CCNode () {
AnchorPoint = CCPoint.AnchorMiddle,
};
size *= 1.2f;
var lbl = new CCLabel(text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont)
{
Color = color,
AnchorPoint = CCPoint.AnchorMiddle,
};
lbl.LabelFormat.Alignment = CCTextAlignment.Center;
node.ContentSize = lbl.ScaledContentSize;
lbl.Position = node.ContentSize.Center;
if (shadowColor != CCColor3B.Magenta)
{
node.ContentSize = lbl.ContentSize + 2;
var shadowLbl = new CCLabel (text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont) {
Color = shadowColor,
AnchorPoint = CCPoint.AnchorMiddle,
Position = new CCPoint(node.ContentSize.Center.X + 2, node.ContentSize.Center.Y - 2)
};
shadowLbl.LabelFormat.Alignment = CCTextAlignment.Center;
node.AddChild (shadowLbl);
}
node.AddChild (lbl);
return node;
}
示例9: NodeToWorld3D
public NodeToWorld3D()
{
//
// This code tests that nodeToParent works OK:
// - It tests different anchor Points
// - It tests different children anchor points
parent = new CCNode();
parent.AnchorPoint = new CCPoint(0.5f, 0.5f);
AddChild(parent);
back = new CCSprite(TestResource.s_back3);
parent.AddChild(back, -10);
back.AnchorPoint = CCPoint.Zero;
var item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
menu = new CCMenu(item);
menu.AlignItemsVertically();
back.AddChild(menu);
item.RepeatForever(CocosNodeTestStaticLibrary.nodeRotate);
back.RepeatForever(CocosNodeTestStaticLibrary.nodeMove, CocosNodeTestStaticLibrary.nodeMove.Reverse());
parent.RunAction (CocosNodeTestStaticLibrary.nodeOrbit);
}
示例10: AddedToScene
protected override void AddedToScene()
{
base.AddedToScene();
contentLayer = new CCLayer();
Window.IsUseDepthTesting = true;
node = new CCNode(Layer.VisibleBoundsWorldspace.Size);
node.AnchorPoint = CCPoint.AnchorMiddle;
node.IgnoreAnchorPointForPosition = true;
AddChild(contentLayer);
contentLayer.AddChild(node);
dir = 1;
time = 0;
sprites = new CCSprite[numOfSprites];
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;
}
}
示例11: CCGridActionState
public CCGridActionState (CCGridAction action, CCNode target) : base (action, target)
{
GridSize = action.GridSize;
CCGridBase targetGrid = Target.Grid;
if (targetGrid != null && targetGrid.ReuseGrid > 0)
{
Grid = targetGrid;
if (targetGrid.Active && targetGrid.GridSize.X == GridSize.X && targetGrid.GridSize.Y == GridSize.Y)
{
targetGrid.Reuse ();
}
else
{
Debug.Assert (false);
}
}
else
{
if (targetGrid != null && targetGrid.Active)
{
targetGrid.Active = false;
}
CCGridBase newgrid = Grid;
Target.Grid = newgrid;
Target.Grid.Active = true;
}
}
示例12: CCFiniteTimeActionState
public CCFiniteTimeActionState (CCFiniteTimeAction action, CCNode target)
: base (action, target)
{
Duration = action.Duration;
Elapsed = 0.0f;
firstTick = true;
}
示例13: CCShuffleTilesState
public CCShuffleTilesState (CCShuffleTiles action, CCNode target) : base (action, target)
{
CCGridSize gridSize = action.GridSize;
TilesCount = gridSize.X * gridSize.Y;
int[] shuffledTilesOrder = new int[TilesCount];
int i, j, f = 0;
for (i = 0; i < TilesCount; i++) {
shuffledTilesOrder [i] = i;
}
if (action.Seed != CCShuffleTiles.NoSeedSpecified) {
CCRandom.Next (action.Seed);
}
Shuffle (ref shuffledTilesOrder, TilesCount);
TilesOrder = shuffledTilesOrder;
Tiles = new CCTile[TilesCount];
for (i = 0; i < gridSize.X; ++i) {
for (j = 0; j < gridSize.Y; ++j) {
Tiles [f] = new CCTile {
Position = new CCPoint (i, j),
StartPosition = new CCPoint (i, j),
Delta = GetDelta (i, j)
};
f++;
}
}
}
示例14: CCLens3DState
public CCLens3DState (CCLens3D action, CCNode target) : base (action, target)
{
Position = action.Position;
Radius = action.Radius;
LensScale = action.LensScale;
Concave = action.Concave;
}
示例15: CCRotateAroundToState
public CCRotateAroundToState(CCRotateAroundTo action, CCNode target)
: base(action, target)
{
DistanceAngle = action.DistanceAngle;
Origin = action.Origin;
StartPosition = target.Position;
RotationDirection = action.RotationDirection;
offsetX = StartPosition.X - Origin.X;
offsetY = StartPosition.Y - Origin.Y;
// Calculate the Starting Angle of the target in relation to the Origin in which it is to rotate
// Math.Atan2 returns the mathematical angle which is counter-clockwise [-Math.PI, +Math.PI]
StartAngle = CCMathHelper.ToDegrees((float)Math.Atan2(offsetY, offsetX));
// Map value [0,360]
StartAngle = (StartAngle + 360) % 360;
// Now we work out how far we actually have to rotate
DiffAngle = DistanceAngle - StartAngle;
// Map value [0,360] and take into consideration the direction of rotation - CCW or CW
DiffAngle = (DiffAngle + 360 * RotationDirection) % 360;
theta = CCMathHelper.ToRadians(DiffAngle);
}