本文整理汇总了C#中Cocos2D.CCMenu.AlignItemsVertically方法的典型用法代码示例。如果您正苦于以下问题:C# CCMenu.AlignItemsVertically方法的具体用法?C# CCMenu.AlignItemsVertically怎么用?C# CCMenu.AlignItemsVertically使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cocos2D.CCMenu
的用法示例。
在下文中一共展示了CCMenu.AlignItemsVertically方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override bool Init()
{
InitWithColor(new CCColor4B(0, 0, 255, 255));
var item0 = new CCMenuItemFont("(3) Touch to pushScene (self)", item0Clicked);
var item1 = new CCMenuItemFont("(3) Touch to popScene", item1Clicked);
var item2 = new CCMenuItemFont("(3) Touch to popToRootScene", item2Clicked);
var item3 = new CCMenuItemFont("(3) Touch to popToSceneStackLevel(2)", item3Clicked);
CCMenu menu = new CCMenu(item0, item1, item2, item3);
menu.AlignItemsVertically();
AddChild(menu);
CCSize s = CCDirector.SharedDirector.WinSize;
CCSprite sprite = new CCSprite(s_pPathGrossini);
AddChild(sprite);
sprite.Position = new CCPoint(s.Width /2, 40);
CCActionInterval rotate = new CCRotateBy (2, 360);
CCAction repeat = new CCRepeatForever (rotate);
sprite.RunAction(repeat);
Schedule(testDealloc);
return true;
}
示例2: NodeToWorld
public NodeToWorld()
{
//
// This code tests that nodeToParent works OK:
// - It tests different anchor Points
// - It tests different children anchor points
CCSprite back = new CCSprite(TestResource.s_back3);
AddChild(back, -10);
back.AnchorPoint = (new CCPoint(0, 0));
CCSize backSize = back.ContentSize;
CCMenuItem item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
CCMenu menu = new CCMenu(item);
menu.AlignItemsVertically();
menu.Position = (new CCPoint(backSize.Width / 2, backSize.Height / 2));
back.AddChild(menu);
CCActionInterval rot = new CCRotateBy (5, 360);
CCAction fe = new CCRepeatForever (rot);
item.RunAction(fe);
CCActionInterval move = new CCMoveBy (3, new CCPoint(200, 0));
var move_back = (CCActionInterval) move.Reverse();
CCFiniteTimeAction seq = new CCSequence(move, move_back);
CCAction fe2 = new CCRepeatForever ((CCActionInterval) seq);
back.RunAction(fe2);
}
示例3: reset
public void reset()
{
int localtag = 0;
localtag++;
// TO TRIGGER THE BUG:
// remove the itself from parent from an action
// The menu will be removed, but the instance will be alive
// and then a new node will be allocated occupying the memory.
// => CRASH BOOM BANG
CCNode node = GetChildByTag(localtag - 1);
CCLog.Log("Menu: %p", node);
RemoveChild(node, false);
// [self removeChildByTag:localtag-1 cleanup:NO];
CCMenuItem item1 = new CCMenuItemFont("One", menuCallback);
CCLog.Log("MenuItemFont: %p", item1);
CCMenuItem item2 = new CCMenuItemFont("Two", menuCallback);
CCMenu menu = new CCMenu(item1, item2);
menu.AlignItemsVertically();
float x = CCRandom.Next() * 50;
float y = CCRandom.Next() * 50;
menu.Position = menu.Position + new CCPoint(x, y);
AddChild(menu, 0, localtag);
//[self check:self];
}
示例4: SceneTestLayer1
public SceneTestLayer1()
{
CCMenuItemFont item1 = new CCMenuItemFont("(1) Test pushScene", onPushScene);
CCMenuItemFont item2 = new CCMenuItemFont("(1) Test pushScene w/transition", onPushSceneTran);
CCMenuItemFont item3 = new CCMenuItemFont("(1) Quit", onQuit);
_PopMenuItem = new CCMenuItemFont("(1) Test popScene w/transition", onPopSceneTran);
_TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem);
_TheMenu.AlignItemsVertically();
AddChild(_TheMenu);
CCSize s = CCDirector.SharedDirector.WinSize;
CCSprite sprite = new CCSprite(s_pPathGrossini);
AddChild(sprite);
sprite.Position = new CCPoint(s.Width - 40, s.Height / 2);
CCActionInterval rotate = new CCRotateBy (2, 360);
CCAction repeat = new CCRepeatForever (rotate);
sprite.RunAction(repeat);
}
示例5: RenderTextureSave
public RenderTextureSave()
{
CCSize s = CCDirector.SharedDirector.WinSize;
// create a render texture, this is what we are going to draw into
m_pTarget = new CCRenderTexture((int) s.Width, (int) s.Height, SurfaceFormat.Color, DepthFormat.None, RenderTargetUsage.PreserveContents);
// Let's clear the rendertarget here so that we start off fresh.
// Some platforms do not seem to be initializing the rendertarget color so this will make sure the background shows up colored instead of
// what looks like non initialized. Mostly MacOSX for now.
m_pTarget.Clear(0,0,0,255);
m_pTarget.Position = new CCPoint(s.Width / 2, s.Height / 2);
// It's possible to modify the RenderTexture blending function by
//CCBlendFunc tbf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
//m_pTarget.Sprite.BlendFunc = tbf;
// note that the render texture is a CCNode, and contains a sprite of its texture for convience,
// so we can just parent it to the scene like any other CCNode
AddChild(m_pTarget, -1);
// create a brush image to draw into the texture with
m_pBrush = new CCSprite("Images/fire");
// It's possible to modify the Brushes blending function by
CCBlendFunc bbf = new CCBlendFunc (CCOGLES.GL_ONE, CCOGLES.GL_ONE_MINUS_SRC_ALPHA);
m_pBrush.BlendFunc = bbf;
m_pBrush.Color = new CCColor3B (Color.Red);
m_pBrush.Opacity = 20;
TouchEnabled = true;
// Save Image menu
CCMenuItemFont.FontSize = 16;
CCMenuItem item1 = new CCMenuItemFont("Save Image", saveImage);
CCMenuItem item2 = new CCMenuItemFont("Clear", clearImage);
var menu = new CCMenu(item1, item2);
AddChild(menu);
menu.AlignItemsVertically();
menu.Position = new CCPoint(s.Width - 80, s.Height - 30);
}
示例6: Init
public override bool Init()
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if (base.Init())
{
TouchEnabled = true;
// ask director the the window size
CCSize size = CCDirector.SharedDirector.WinSize;
CCLayerColor layer;
for (int i = 0; i < 5; i++)
{
layer = new CCLayerColor(new CCColor4B((byte)(i*20), (byte)(i*20), (byte)(i*20),255));
layer.ContentSize = new CCSize(i * 100, i * 100);
layer.Position = new CCPoint(size.Width / 2, size.Height / 2);
layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
layer.IgnoreAnchorPointForPosition = true;
AddChild(layer, -1 - i);
}
// create and initialize a Label
CCLabelTTF label = new CCLabelTTF("Hello World", "Marker Felt", 64);
CCMenuItem item1 = new CCMenuItemFont("restart", restart);
CCMenu menu = new CCMenu(item1);
menu.AlignItemsVertically();
menu.Position = new CCPoint(size.Width / 2, 100);
AddChild(menu);
// position the label on the center of the screen
label.Position = new CCPoint(size.Width / 2, size.Height / 2);
// add the label as a child to this Layer
AddChild(label);
return true;
}
return false;
}
示例7: SceneTestLayer2
public SceneTestLayer2()
{
m_timeCounter = 0;
CCMenuItemFont item1 = new CCMenuItemFont("(2) replaceScene", onReplaceScene);
CCMenuItemFont item2 = new CCMenuItemFont("(2) replaceScene w/transition", onReplaceSceneTran);
CCMenuItemFont item3 = new CCMenuItemFont("(2) Go Back", onGoBack);
_PopMenuItem = new CCMenuItemFont("(2) Test popScene w/transition", onPopSceneTran);
_TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem);
_TheMenu.AlignItemsVertically();
AddChild(_TheMenu);
CCSize s = CCDirector.SharedDirector.WinSize;
CCSprite sprite = new CCSprite(s_pPathGrossini);
AddChild(sprite);
sprite.Position = new CCPoint(s.Width - 40, s.Height / 2);
CCActionInterval rotate = new CCRotateBy (2, 360);
CCAction repeat = new CCRepeatForever (rotate);
sprite.RunAction(repeat);
Schedule(testDealloc);
}
示例8: BitmapFontMultiLineAlignment
public BitmapFontMultiLineAlignment()
{
TouchEnabled = true;
// ask director the the window size
CCSize size = CCDirector.SharedDirector.WinSize;
// create and initialize a Label
m_pLabelShouldRetain = new CCLabelBMFont(LongSentencesExample, "fonts/markerFelt.fnt", size.Width / 1.5f,
CCTextAlignment.Center);
m_pArrowsBarShouldRetain = new CCSprite("Images/arrowsBar");
m_pArrowsShouldRetain = new CCSprite("Images/arrows");
CCMenuItemFont.FontSize = 20;
CCMenuItemFont longSentences = new CCMenuItemFont("Long Flowing Sentences", stringChanged);
CCMenuItemFont lineBreaks = new CCMenuItemFont("Short Sentences With Intentional Line Breaks", stringChanged);
CCMenuItemFont mixed = new CCMenuItemFont("Long Sentences Mixed With Intentional Line Breaks", stringChanged);
CCMenu stringMenu = new CCMenu(longSentences, lineBreaks, mixed);
stringMenu.AlignItemsVertically();
longSentences.Color = CCTypes.CCRed;
m_pLastSentenceItem = longSentences;
longSentences.Tag = LongSentences;
lineBreaks.Tag = LineBreaks;
mixed.Tag = Mixed;
CCMenuItemFont.FontSize = 30;
CCMenuItemFont left = new CCMenuItemFont("Left", alignmentChanged);
CCMenuItemFont center = new CCMenuItemFont("Center", alignmentChanged);
CCMenuItemFont right = new CCMenuItemFont("Right", alignmentChanged);
CCMenu alignmentMenu = new CCMenu(left, center, right);
alignmentMenu.AlignItemsHorizontallyWithPadding(alignmentItemPadding);
center.Color = CCTypes.CCRed;
m_pLastAlignmentItem = center;
left.Tag = (LeftAlign);
center.Tag = (CenterAlign);
right.Tag = (RightAlign);
// position the label on the center of the screen
m_pLabelShouldRetain.Position = new CCPoint(size.Width / 2, size.Height / 2);
m_pArrowsBarShouldRetain.Visible = (false);
float arrowsWidth = (ArrowsMax - ArrowsMin) * size.Width;
m_pArrowsBarShouldRetain.ScaleX = (arrowsWidth / m_pArrowsBarShouldRetain.ContentSize.Width);
m_pArrowsBarShouldRetain.Position = new CCPoint(((ArrowsMax + ArrowsMin) / 2) * size.Width, m_pLabelShouldRetain.Position.Y);
snapArrowsToEdge();
stringMenu.Position = new CCPoint(size.Width / 2, size.Height - menuItemPaddingCenter);
alignmentMenu.Position = new CCPoint(size.Width / 2, menuItemPaddingCenter + 15);
AddChild(m_pLabelShouldRetain);
AddChild(m_pArrowsBarShouldRetain);
AddChild(m_pArrowsShouldRetain);
AddChild(stringMenu);
AddChild(alignmentMenu);
}
示例9: MenuLayer1
public MenuLayer1()
{
CCMenuItemFont.FontSize = 30;
CCMenuItemFont.FontName = "arial";
base.TouchEnabled = true;
// Font Item
CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));
CCMenuItemSprite item1 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback);
// Image Item
CCMenuItem item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2);
// Label Item (LabelAtlas)
CCLabelAtlas labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images", 16, 24, '.');
CCMenuItemLabel item3 = new CCMenuItemLabel(labelAtlas, this.menuCallbackDisabled);
item3.DisabledColor = new CCColor3B(32, 32, 64);
item3.Color = new CCColor3B(200, 200, 255);
// Font Item
CCMenuItemFont item4 = new CCMenuItemFont("I toggle enable items", this.menuCallbackEnable);
item4.FontSizeObj = 20;
item4.FontNameObj = "arial";
// Label Item (CCLabelBMFont)
CCLabelBMFont label = new CCLabelBMFont("configuration", "fonts/bitmapFontTest3.fnt");
CCMenuItemLabel item5 = new CCMenuItemLabel(label, this.menuCallbackConfig);
// Testing issue #500
item5.Scale = 0.8f;
// Events
CCMenuItemFont.FontName = "arial";
CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest);
// Font Item
CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit);
CCActionInterval color_action = new CCTintBy (0.5f, 0, -255, -255);
CCActionInterval color_back = (CCActionInterval)color_action.Reverse();
CCFiniteTimeAction seq = CCSequence.FromActions(color_action, color_back);
item7.RunAction(new CCRepeatForever ((CCActionInterval)seq));
CCMenu menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7);
menu.AlignItemsVertically();
// elastic effect
CCSize s = CCDirector.SharedDirector.WinSize;
int i = 0;
CCNode child;
var pArray = menu.Children;
object pObject = null;
if (pArray.Count > 0)
{
for (int j = 0; j < pArray.Count; j++)
{
pObject = pArray[j];
if (pObject == null)
break;
child = (CCNode)pObject;
CCPoint dstPoint = child.Position;
int offset = (int)(s.Width / 2 + 50);
if (i % 2 == 0)
offset = -offset;
child.Position = new CCPoint(dstPoint.X + offset, dstPoint.Y);
child.RunAction(new CCEaseElasticOut(new CCMoveBy (2, new CCPoint(dstPoint.X - offset, 0)), 0.35f));
i++;
}
}
m_disabledItem = item3;
m_disabledItem.Enabled = false;
AddChild(menu);
}
示例10: MenuLayer5
public MenuLayer5()
{
var randomFilterMenuItem = CocosExtensions.CreateScaledMenuItemLabel(_targetButtonSize, 20, 4, CCColor3B.Blue, new CCColor3B(Microsoft.Xna.Framework.Color.Black),
new CCColor3B(Microsoft.Xna.Framework.Color.White), "Random Surprise!", () =>
{
CCLog.Log("Random action");
});
CocosExtensions.AddJiggle(randomFilterMenuItem);
var backMenuItem = CocosExtensions.CreateScaledMenuItemLabel(_targetButtonSize, 20, 4, CCColor3B.Blue, new CCColor3B(Microsoft.Xna.Framework.Color.Black),
new CCColor3B(Microsoft.Xna.Framework.Color.White), "Back", null);
var backMenuItemToggle = new CCMenuItemToggle((o) =>
{
CCLog.Log("Back toggle touched");
},
new[] { backMenuItem });
CocosExtensions.AddJiggle(backMenuItemToggle);
var menu = new CCMenu(new[]
{
randomFilterMenuItem,
backMenuItemToggle,
});
AddChild(menu);
menu.Position = CCDirector.SharedDirector.WinSize.Center;
menu.AlignItemsVertically();
}