本文整理汇总了C#中Cocos2D.CCNode.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# CCNode.AddChild方法的具体用法?C# CCNode.AddChild怎么用?C# CCNode.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cocos2D.CCNode
的用法示例。
在下文中一共展示了CCNode.AddChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TextLayer
public TextLayer()
{
InitWithColor(CCTypes.CreateColor(32, 32, 32, 255));
float x, y;
CCSize size = CCDirector.SharedDirector.WinSize;
x = size.Width;
y = size.Height;
CCNode node = new CCNode ();
CCActionInterval effect = getAction();
node.RunAction(effect);
AddChild(node, 0, EffectTestScene.kTagBackground);
CCSprite bg = new CCSprite(TestResource.s_back3);
node.AddChild(bg, 0);
bg.AnchorPoint = new CCPoint(0.5f, 0.5f);
bg.Position = new CCPoint(size.Width / 2, size.Height / 2);
CCSprite grossini = new CCSprite(TestResource.s_pPathSister2);
node.AddChild(grossini, 1);
grossini.Position = new CCPoint(x / 3, y / 2);
CCActionInterval sc = new CCScaleBy(2, 5);
CCFiniteTimeAction sc_back = sc.Reverse();
grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back))));
//grossini.runAction(effect);
CCSprite tamara = new CCSprite(TestResource.s_pPathSister1);
node.AddChild(tamara, 1);
tamara.Position = new CCPoint(2 * x / 3, y / 2);
CCActionInterval sc2 = new CCScaleBy(2, 5);
CCFiniteTimeAction sc2_back = sc2.Reverse();
tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back))));
CCLabelTTF label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32);
label.Position = new CCPoint(x / 2, y - 80);
AddChild(label);
label.Tag = EffectTestScene.kTagLabel;
CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);
CCMenu menu = new CCMenu(item1, item2, item3);
menu.Position = new CCPoint(0, 0);
item1.Position = new CCPoint(size.Width / 2 - 100, 30);
item2.Position = new CCPoint(size.Width / 2, 30);
item3.Position = new CCPoint(size.Width / 2 + 100, 30);
AddChild(menu, 1);
Schedule(checkAnim);
}
示例2: TextLayer
public TextLayer()
{
InitWithColor(CCTypes.CreateColor(32, 32, 32, 255));
var node = new CCNode();
CCActionInterval effect = getAction();
node.RunAction(effect);
AddChild(node, 0, EffectTestScene.kTagBackground);
var bg = new CCSprite(TestResource.s_back3);
node.AddChild(bg, 0);
bg.AnchorPoint = new CCPoint(0.5f, 0.5f);
bg.Position = CCVisibleRect.Center;
var grossini = new CCSprite(TestResource.s_pPathSister2);
node.AddChild(grossini, 1);
grossini.Position = new CCPoint(CCVisibleRect.Left.X + CCVisibleRect.VisibleRect.Size.Width / 3,
CCVisibleRect.Center.Y);
CCActionInterval sc = new CCScaleBy(2, 5);
CCFiniteTimeAction sc_back = sc.Reverse();
grossini.RunAction(new CCRepeatForever((new CCSequence(sc, sc_back))));
var tamara = new CCSprite(TestResource.s_pPathSister1);
node.AddChild(tamara, 1);
tamara.Position = new CCPoint(CCVisibleRect.Left.X + 2 * CCVisibleRect.VisibleRect.Size.Width / 3,
CCVisibleRect.Center.Y);
CCActionInterval sc2 = new CCScaleBy(2, 5);
CCFiniteTimeAction sc2_back = sc2.Reverse();
tamara.RunAction(new CCRepeatForever((new CCSequence(sc2, sc2_back))));
var label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32);
label.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Top.Y - 80);
AddChild(label);
label.Tag = EffectTestScene.kTagLabel;
var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);
var menu = new CCMenu(item1, item2, item3);
menu.Position = CCPoint.Zero;
item1.Position = new CCPoint(CCVisibleRect.Center.X - item2.ContentSize.Width * 2,
CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
item2.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
item3.Position = new CCPoint(CCVisibleRect.Center.X + item2.ContentSize.Width * 2,
CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
AddChild(menu, 1);
Schedule(checkAnim);
}
示例3: Init
public override bool Init()
{
if (base.Init())
{
CCSize screenSize = CCDirector.SharedDirector.WinSize;
CCNode layer = new CCNode();
layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
AddChild(layer, 1);
float layer_width = 0;
// Create the colour picker
CCControlColourPicker colourPicker = new CCControlColourPicker();
colourPicker.Color = new CCColor3B(37, 46, 252);
colourPicker.Position = new CCPoint(colourPicker.ContentSize.Width / 2, 0);
// Add it to the layer
layer.AddChild(colourPicker);
// Add the target-action pair
colourPicker.AddTargetWithActionForControlEvents(this, ColourValueChanged,
CCControlEvent.ValueChanged);
layer_width += colourPicker.ContentSize.Width;
// Add the black background for the text
CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
background.ContentSize = new CCSize(150, 50);
background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
layer.AddChild(background);
layer_width += background.ContentSize.Width;
_colorLabel = new CCLabelTTF("#color", "Arial", 26);
_colorLabel.Position = background.Position;
layer.AddChild(_colorLabel);
// Set the layer size
layer.ContentSize = new CCSize(layer_width, 0);
layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
// Update the color text
ColourValueChanged(colourPicker, CCControlEvent.ValueChanged);
return true;
}
return false;
}
示例4: Init
public override bool Init()
{
if (base.Init())
{
CCSize screenSize = CCDirector.SharedDirector.WinSize;
CCNode layer = new CCNode ();
layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
AddChild(layer, 1);
float layer_width = 0.0f;
// Add the black background for the text
CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground");
background.ContentSize = new CCSize(80, 50);
background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
layer.AddChild(background);
layer_width += background.ContentSize.Width;
m_pDisplayValueLabel = new CCLabelTTF("#color", "Arial", 30);
m_pDisplayValueLabel.Position = background.Position;
layer.AddChild(m_pDisplayValueLabel);
// Create the switch
CCControlSwitch switchControl = new CCControlSwitch
(
new CCSprite("extensions/switch-mask"),
new CCSprite("extensions/switch-on"),
new CCSprite("extensions/switch-off"),
new CCSprite("extensions/switch-thumb"),
new CCLabelTTF("On", "Arial", 16),
new CCLabelTTF("Off", "Arial", 16)
);
switchControl.Position = new CCPoint(layer_width + 10 + switchControl.ContentSize.Width / 2, 0);
layer.AddChild(switchControl);
switchControl.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged);
// Set the layer size
layer.ContentSize = new CCSize(layer_width, 0);
layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
// Update the value label
valueChanged(switchControl, CCControlEvent.ValueChanged);
return true;
}
return false;
}
示例5: Init
public override bool Init()
{
if (base.Init())
{
CCSize screenSize = CCDirector.SharedDirector.WinSize;
var layer = new CCNode();
layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
AddChild(layer, 1);
double layer_width = 0;
// Add the black background for the text
CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
background.ContentSize = new CCSize(80, 50);
background.Position = new CCPoint((float) layer_width + background.ContentSize.Width / 2.0f, 0);
layer.AddChild(background);
layer_width += background.ContentSize.Width;
DisplayValueLabel = new CCLabelTTF("", "Arial", 30);
_displayValueLabel.Position = background.Position;
layer.AddChild(_displayValueLabel);
// Add the slider
var potentiometer = new CCControlPotentiometer("extensions/potentiometerTrack.png"
,
"extensions/potentiometerProgress.png"
, "extensions/potentiometerButton.png");
potentiometer.Position = new CCPoint((float) layer_width + 10 + potentiometer.ContentSize.Width / 2, 0);
// When the value of the slider will change, the given selector will be call
potentiometer.AddTargetWithActionForControlEvents(this, ValueChanged, CCControlEvent.ValueChanged);
layer.AddChild(potentiometer);
layer_width += potentiometer.ContentSize.Width;
// Set the layer size
layer.ContentSize = new CCSize((float) layer_width, 0);
layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
// Update the value label
ValueChanged(potentiometer, CCControlEvent.ValueChanged);
return true;
}
return false;
}
示例6: 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.
//
m_dir = 1;
m_time = 0;
CCSize s = CCDirector.SharedDirector.WinSize;
float step = s.Width / 12;
CCNode node = new CCNode ();
// 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 = new CCSprite("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 = new CCSprite("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(new CCOrbitCamera(10, 1, 0, 0, 360, 0, 0));
}
示例7: Init
public override bool Init()
{
if (base.Init())
{
CCSize screenSize = CCDirector.SharedDirector.WinSize;
var layer = new CCNode();
layer.Position = screenSize.Center;
AddChild(layer, 1);
float layer_width = 0;
// Add the black background for the text
CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
background.ContentSize = new CCSize(100, 50);
background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
layer.AddChild(background);
DisplayValueLabel = new CCLabelTTF("0", "Arial", 26);
_displayValueLabel.Position = background.Position;
layer.AddChild(_displayValueLabel);
layer_width += background.ContentSize.Width;
CCControlStepper stepper = MakeControlStepper();
stepper.Position = new CCPoint(layer_width + 10 + stepper.ContentSize.Width / 2, 0);
stepper.AddTargetWithActionForControlEvents(this, ValueChanged,
CCControlEvent.ValueChanged);
layer.AddChild(stepper);
layer_width += stepper.ContentSize.Width;
// Set the layer size
layer.ContentSize = new CCSize(layer_width, 0);
layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
// Update the value label
ValueChanged(stepper, CCControlEvent.ValueChanged);
return true;
}
return false;
}
示例8: SpriteChildrenVisibilityIssue665
public SpriteChildrenVisibilityIssue665()
{
CCSize s = CCDirector.SharedDirector.WinSize;
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");
CCNode aParent;
CCSprite sprite1, sprite2, sprite3;
//
// SpriteBatchNode
//
// parents
aParent = new CCSpriteBatchNode("animations/grossini", 50);
aParent.Position = (new CCPoint(s.Width / 3, s.Height / 2));
AddChild(aParent, 0);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(0, 0));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
// test issue #665
sprite1.Visible = false;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, 2);
//
// Sprite
//
aParent = new CCNode ();
aParent.Position = (new CCPoint(2 * s.Width / 3, s.Height / 2));
AddChild(aParent, 0);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(0, 0));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
// test issue #665
sprite1.Visible = false;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, 2);
}
示例9: SpriteHybrid
public SpriteHybrid()
{
CCSize s = CCDirector.SharedDirector.WinSize;
// parents
CCNode parent1 = new CCNode ();
CCSpriteBatchNode parent2 = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(parent1, 0, (int)kTags.kTagNode);
AddChild(parent2, 0, (int)kTags.kTagSpriteBatchNode);
// IMPORTANT:
// The sprite frames will be cached AND RETAINED, and they won't be released unless you call
// CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames);
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");
// create 250 sprites
// only show 80% of them
for (int i = 0; i < 250; i++)
{
int spriteIdx = (int)(CCRandom.NextDouble() * 14);
string str = "";
string temp = "";
if (spriteIdx+1<10)
{
temp = "0" + (spriteIdx+1);
}
else
{
temp = (spriteIdx+1).ToString();
}
str = string.Format("grossini_dance_{0}.png", temp);
CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str);
CCSprite sprite = new CCSprite(frame);
parent1.AddChild(sprite, i, i);
float x = -1000;
float y = -1000;
if (CCRandom.NextDouble() < 0.2f)
{
x = (float)(CCRandom.NextDouble() * s.Width);
y = (float)(CCRandom.NextDouble() * s.Height);
}
sprite.Position = (new CCPoint(x, y));
CCActionInterval action = new CCRotateBy (4, 360);
sprite.RunAction(new CCRepeatForever (action));
}
m_usingSpriteBatchNode = false;
Schedule(reparentSprite, 2);
}
示例10: AddSpriteToTargetWithPosAndAnchor
public static CCSprite AddSpriteToTargetWithPosAndAnchor(string spriteName, CCNode target, CCPoint pos, CCPoint anchor)
{
var sprite = new CCSprite(spriteName);
if (sprite == null)
return null;
sprite.Position = pos;
sprite.AnchorPoint = anchor;
target.AddChild(sprite);
return sprite;
}
示例11: Init
public override bool Init()
{
if (base.Init())
{
CCSize screenSize = CCDirector.SharedDirector.WinSize;
// 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
object pObj = null;
foreach(var title in stringArray)
{
// Creates a button with this string as title
var button = standardButtonWithTitle(title);
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;
}
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);
return true;
}
return false;
}
示例12: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSize s = CCDirector.SharedDirector.WinSize;
// the root object just rotates around
m_root = new CCSprite(s_pPathR1);
AddChild(m_root, 1);
m_root.Position = new CCPoint(s.Width / 2, s.Height / 2);
// the target object is offset from root, and the streak is moved to follow it
m_target = new CCSprite(s_pPathR1);
m_root.AddChild(m_target);
m_target.Position = new CCPoint(s.Width / 4, 0);
// create the streak object and add it to the scene
streak = CCMotionStreak.Create(2, 3, 32, CCTypes.CCGreen, s_streak);
streak.FastMode = true;
AddChild(streak);
// schedule an update on each frame so we can syncronize the streak with the target
Schedule(onUpdate);
var a1 = new CCRotateBy (2, 360);
var action1 = new CCRepeatForever (a1);
var motion = new CCMoveBy (2, new CCPoint(100, 0));
m_root.RunAction(new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(motion, motion.Reverse())));
m_root.RunAction(action1);
var colorAction = new CCRepeatForever ((CCActionInterval)
CCSequence.FromActions(
new CCTintTo (0.2f, 255, 0, 0),
new CCTintTo (0.2f, 0, 255, 0),
new CCTintTo (0.2f, 0, 0, 255),
new CCTintTo (0.2f, 0, 255, 255),
new CCTintTo (0.2f, 255, 255, 0),
new CCTintTo (0.2f, 255, 0, 255),
new CCTintTo (0.2f, 255, 255, 255)
)
);
streak.RunAction(colorAction);
}
示例13: SpriteChildrenAnchorPoint
public SpriteChildrenAnchorPoint()
{
CCSize s = CCDirector.SharedDirector.WinSize;
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");
CCNode aParent;
CCSprite sprite1, sprite2, sprite3, sprite4, point;
//
// SpriteBatchNode
//
// parents
aParent = new CCNode ();
AddChild(aParent, 0);
// anchor (0,0)
sprite1 = new CCSprite("grossini_dance_08.png");
sprite1.Position = (new CCPoint(s.Width / 4, s.Height / 2));
sprite1.AnchorPoint = (new CCPoint(0, 0));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
sprite4 = new CCSprite("grossini_dance_04.png");
sprite4.Position = (new CCPoint(0, 0));
sprite4.Scale = 0.5f;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, -2);
sprite1.AddChild(sprite4, 3);
point = new CCSprite("Images/r1");
point.Scale = 0.25f;
point.Position = sprite1.Position;
AddChild(point, 10);
// anchor (0.5, 0.5)
sprite1 = new CCSprite("grossini_dance_08.png");
sprite1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
sprite1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
sprite4 = new CCSprite("grossini_dance_04.png");
sprite4.Position = (new CCPoint(0, 0));
sprite4.Scale = 0.5f;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, -2);
sprite1.AddChild(sprite4, 3);
point = new CCSprite("Images/r1");
point.Scale = 0.25f;
point.Position = sprite1.Position;
AddChild(point, 10);
// anchor (1,1)
sprite1 = new CCSprite("grossini_dance_08.png");
sprite1.Position = (new CCPoint(s.Width / 2 + s.Width / 4, s.Height / 2));
sprite1.AnchorPoint = new CCPoint(1, 1);
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
sprite4 = new CCSprite("grossini_dance_04.png");
sprite4.Position = (new CCPoint(0, 0));
sprite4.Scale = 0.5f;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, -2);
sprite1.AddChild(sprite4, 3);
point = new CCSprite("Images/r1");
point.Scale = 0.25f;
point.Position = sprite1.Position;
AddChild(point, 10);
}
示例14: initWithSubTest
public void initWithSubTest(int nSubTest, CCNode p)
{
subtestNumber = nSubTest;
parent = p;
batchNode = null;
/*
* Tests:
* 1: 1 (32-bit) PNG sprite of 52 x 139
* 2: 1 (32-bit) PNG Batch Node using 1 sprite of 52 x 139
* 3: 1 (16-bit) PNG Batch Node using 1 sprite of 52 x 139
* 4: 1 (4-bit) PVRTC Batch Node using 1 sprite of 52 x 139
* 5: 14 (32-bit) PNG sprites of 85 x 121 each
* 6: 14 (32-bit) PNG Batch Node of 85 x 121 each
* 7: 14 (16-bit) PNG Batch Node of 85 x 121 each
* 8: 14 (4-bit) PVRTC Batch Node of 85 x 121 each
* 9: 64 (32-bit) sprites of 32 x 32 each
*10: 64 (32-bit) PNG Batch Node of 32 x 32 each
*11: 64 (16-bit) PNG Batch Node of 32 x 32 each
*12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each
*/
// purge textures
CCTextureCache mgr = CCTextureCache.SharedTextureCache;
// [mgr removeAllTextures];
mgr.RemoveTexture(mgr.AddImage("Images/grossinis_sister1"));
mgr.RemoveTexture(mgr.AddImage("Images/grossini_dance_atlas"));
mgr.RemoveTexture(mgr.AddImage("Images/spritesheet1"));
switch (subtestNumber)
{
case 1:
case 4:
case 7:
break;
case 2:
CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.RGBA8888;
batchNode = new CCSpriteBatchNode("Images/grossinis_sister1", 100);
p.AddChild(batchNode, 0);
break;
case 3:
CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.RGBA4444;
batchNode = new CCSpriteBatchNode("Images/grossinis_sister1", 100);
p.AddChild(batchNode, 0);
break;
case 5:
CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.RGBA8888;
batchNode = new CCSpriteBatchNode("Images/grossini_dance_atlas", 100);
p.AddChild(batchNode, 0);
break;
case 6:
CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.RGBA4444;
batchNode = new CCSpriteBatchNode("Images/grossini_dance_atlas", 100);
p.AddChild(batchNode, 0);
break;
///
case 8:
CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.RGBA8888;
batchNode = new CCSpriteBatchNode("Images/spritesheet1", 100);
p.AddChild(batchNode, 0);
break;
case 9:
CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.RGBA4444;
batchNode = new CCSpriteBatchNode("Images/spritesheet1", 100);
p.AddChild(batchNode, 0);
break;
default:
break;
}
//if (batchNode != null)
//{
// batchNode.retain();
//}
CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.Default;
}
示例15: Init
public override bool Init()
{
if (base.Init())
{
CCSize screenSize = CCDirector.SharedDirector.WinSize;
var layer = new CCNode ();
AddChild(layer, 1);
int space = 10; // px
float max_w = 0, max_h = 0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
// Add the buttons
var button = standardButtonWithTitle(CCRandom.Next(30).ToString());
button.SetAdjustBackgroundImage(false); // Tells the button that the background image must not be adjust
// It'll use the prefered size of the background image
button.Position = new CCPoint(button.ContentSize.Width / 2 + (button.ContentSize.Width + space) * i,
button.ContentSize.Height / 2 + (button.ContentSize.Height + space) * j);
layer.AddChild(button);
max_w = Math.Max(button.ContentSize.Width * (i + 1) + space * i, max_w);
max_h = Math.Max(button.ContentSize.Height * (j + 1) + space * j, max_h);
}
}
layer.AnchorPoint = new CCPoint (0.5f, 0.5f);
layer.ContentSize = new CCSize(max_w, max_h);
layer.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);
// Add the black background
var backgroundButton = new CCScale9SpriteFile("extensions/buttonBackground");
backgroundButton.ContentSize = new CCSize(max_w + 14, max_h + 14);
backgroundButton.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);
AddChild(backgroundButton);
return true;
}
return false;
}