本文整理汇总了C#中Button.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetPosition方法的具体用法?C# Button.SetPosition怎么用?C# Button.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button
的用法示例。
在下文中一共展示了Button.SetPosition方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDraggableFish
void CreateDraggableFish()
{
var cache = ResourceCache;
var graphics = Graphics;
// Create a draggable Fish button
draggableFish = new Button();
draggableFish.Texture = cache.GetTexture2D("Textures/UrhoDecal.dds"); // Set texture
draggableFish.BlendMode = BlendMode.Add;
draggableFish.SetSize(128, 128);
draggableFish.SetPosition((graphics.Width - draggableFish.Width)/2, 200);
draggableFish.Name = "Fish";
uiRoot.AddChild(draggableFish);
// Add a tooltip to Fish button
ToolTip toolTip = new ToolTip();
draggableFish.AddChild(toolTip);
toolTip.Position = new IntVector2(draggableFish.Width + 5, draggableFish.Width/2);
// slightly offset from close button
BorderImage textHolder = new BorderImage();
toolTip.AddChild(textHolder);
textHolder.SetStyle("ToolTipBorderImage", null);
var toolTipText = new Text();
textHolder.AddChild(toolTipText);
toolTipText.SetStyle("ToolTipText", null);
toolTipText.Value = "Please drag me!";
// Subscribe draggableFish to Drag Events (in order to make it draggable)
draggableFish.SubscribeToDragBegin(HandleDragBegin);
draggableFish.SubscribeToDragMove(HandleDragMove);
draggableFish.SubscribeToDragEnd(HandleDragEnd);
}
示例2: CreditScene
public CreditScene()
{
//create a panel
Sce.PlayStation.HighLevel.UI.Panel panel = new Sce.PlayStation.HighLevel.UI.Panel();
panel.Width = Director.Instance.GL.Context.GetViewport().Width;
panel.Height = Director.Instance.GL.Context.GetViewport().Height;
Button buttonUI1 = new Button(); //buttons
buttonUI1.Name = "go back";
buttonUI1.Text = "go back";
buttonUI1.Width = 250;
buttonUI1.Height = 50;
buttonUI1.Alpha = 0.8f;
buttonUI1.SetPosition(panel.Width/2.5f,panel.Height - 100);
buttonUI1.TouchEventReceived += (sender, e) => {
Support.SoundSystem.Instance.Play("ButtonClick.wav");
Director.Instance.ReplaceScene(new MenuScene());
};
ImageBox ib = new ImageBox(); //set background images
ib.Width = panel.Width;
ib.Image = new ImageAsset("/Application/resources/Credits.png",false);
ib.Height = panel.Height;
ib.SetPosition(0.0f,0.0f);
//add panel to rootwidget
panel.AddChildLast(buttonUI1);
_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
_uiScene.RootWidget.AddChildLast(ib);
_uiScene.RootWidget.AddChildLast(panel);
UISystem.SetScene(_uiScene);
Scheduler.Instance.ScheduleUpdateForTarget(this,0,false); //run the loop
}
示例3: HandleButtonButtonAction
static void HandleButtonButtonAction(object sender, TouchEventArgs e)
{
//if (e.TouchEvent == TouchEventType.Down)
{
var dialog = new Dialog();
Label label = new Label();
label.X = 10.0f;
label.Y = 50.0f;
label.Text = "Test Dialog";
Button button = new Button();
button.Text = "Hidding Dialog...";
button.TextColor = new UIColor(1.0f, 0.0f, 0.0f, 1.0f);
button.SetPosition(5.0f, 5.0f);
button.ButtonAction += (s, ea) =>
{
dialog.Hide();
};
dialog.AddChildLast(button);
dialog.AddChildLast(label);
dialog.Show();
}
}
示例4: Initialize
public void Initialize()
{
Sce.PlayStation.HighLevel.UI.Panel dialog = new Panel();//create panel
dialog.Width = 960;//only for vita
dialog.Height = 544;
ImageBox ib = new ImageBox(); //set background images
ib.Width = dialog.Width;
ib.Image = new ImageAsset("/Application/resources/lose.png",false);
ib.Height = dialog.Height;
ib.SetPosition(0.0f,0.0f);
Button buttonUI1 = new Button(); //set buttons positions
buttonUI1.Name = "replay";
buttonUI1.Text = "replay";
buttonUI1.Width = 250;
buttonUI1.Height = 50;
buttonUI1.Alpha = 0.8f;
buttonUI1.SetPosition(dialog.Width/15,dialog.Height - 100);
buttonUI1.TouchEventReceived += (sender, e) => {
Support.SoundSystem.Instance.Play("ButtonClick.wav");
Director.Instance.ReplaceScene(new GameScene());
};
Button buttonUI2 = new Button();
buttonUI2.Name = "home";
buttonUI2.Text = "home";
buttonUI2.Width = 250;
buttonUI2.Height = 50;
buttonUI2.Alpha = 0.8f;
buttonUI2.SetPosition(dialog.Width/2.7f,dialog.Height - 100);
buttonUI2.TouchEventReceived += (sender, e) => {
Support.SoundSystem.Instance.Play("ButtonClick.wav");
Director.Instance.ReplaceScene(new MenuScene());
};
Sce.PlayStation.HighLevel.UI.Label scoreLabel = new Sce.PlayStation.HighLevel.UI.Label();
labelSetting(scoreLabel, //total score
"Total Score: " + GameScene.totalScore,
690,
0,
300,
100,
30,
FontStyle.Regular,
new UIColor(255, 0, 0, 255));
dialog.AddChildLast(ib);
dialog.AddChildLast(buttonUI1);
dialog.AddChildLast(buttonUI2);
dialog.AddChildLast(scoreLabel);
_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
_uiScene.RootWidget.AddChildLast(dialog);
UISystem.SetScene(_uiScene); // create menu scene
}
示例5: MenuScene
public MenuScene()
{
this.Camera.SetViewFromViewport();
Panel dialog = new Panel();
dialog.Width = Director.Instance.GL.Context.GetViewport().Width;
dialog.Height = Director.Instance.GL.Context.GetViewport().Height;
ImageBox ib = new ImageBox();
ib.Width = dialog.Width;
ib.Image = new ImageAsset("/Application/images/title.png", false);
ib.Height = dialog.Height;
ib.SetPosition(0.0f, 0.0f);
Button playButton = new Button();
playButton.Name = "buttonPlay";
playButton.Text = "Play Game";
playButton.Width = 300;
playButton.Height = 50;
playButton.Alpha = 0.8f;
playButton.SetPosition(dialog.Width/2 - playButton.Width / 2, 200.0f);
playButton.TouchEventReceived += (sender, e) => {
Director.Instance.ReplaceScene(new GameScene());
};
Button menuButton = new Button();
menuButton.Name = "buttonMenu";
menuButton.Text = "Main Menu";
menuButton.Width = 300;
menuButton.Height = 50;
menuButton.Alpha = 0.8f;
menuButton.SetPosition(dialog.Width/2 - playButton.Width / 2, 250.0f);
menuButton.TouchEventReceived += (sender, e) => {
Director.Instance.ReplaceScene(new TitleScene());
};
dialog.AddChildLast(ib);
dialog.AddChildLast(playButton);
dialog.AddChildLast(menuButton);
_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
_uiScene.RootWidget.AddChildLast(dialog);
UISystem.SetScene(_uiScene);
Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false);
}
示例6: CreateButton
Button CreateButton(int x, int y, int xSize, int ySize, string text)
{
UIElement root = UI.Root;
var cache = ResourceCache;
Font font = cache.GetFont("Fonts/Anonymous Pro.ttf");
// Create the button and center the text onto it
Button button = new Button();
root.AddChild(button);
button.SetStyleAuto(null);
button.SetPosition(x, y);
button.SetSize(xSize, ySize);
Text buttonText = new Text();
button.AddChild(buttonText);
buttonText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
buttonText.SetFont(font, 12);
buttonText.Value = text;
return button;
}
示例7: MenuScene
public MenuScene()
{
Console.WriteLine("--------- menu scene -------");
this.Camera.SetViewFromViewport();//set camera view point
Sce.PlayStation.HighLevel.UI.Panel dialog = new Panel();//create panel
dialog.Width = Director.Instance.GL.Context.GetViewport().Width;
dialog.Height = Director.Instance.GL.Context.GetViewport().Height;
ImageBox ib = new ImageBox(); //set background images
ib.Width = dialog.Width;
ib.Image = new ImageAsset("/Application/resources/menuScene.png",false);
ib.Height = dialog.Height;
ib.SetPosition(0.0f,0.0f);
Button buttonUI1 = new Button(); //set buttons positions
buttonUI1.Name = "buttonPlay";
buttonUI1.Text = "Play Game";
buttonUI1.Width = 250;
buttonUI1.Height = 50;
buttonUI1.Alpha = 0.8f;
buttonUI1.SetPosition(dialog.Width/15,dialog.Height - 100);
buttonUI1.TouchEventReceived += (sender, e) => {
Support.SoundSystem.Instance.Play("ButtonClick.wav");
Director.Instance.ReplaceScene(new GameScene());
};
Button buttonUI2 = new Button();
buttonUI2.Name = "buttonOption";
buttonUI2.Text = "Option";
buttonUI2.Width = 250;
buttonUI2.Height = 50;
buttonUI2.Alpha = 0.8f;
buttonUI2.SetPosition(dialog.Width/2.7f,dialog.Height - 100);
buttonUI2.TouchEventReceived += (sender, e) => {
Support.SoundSystem.Instance.Play("ButtonClick.wav");
Director.Instance.ReplaceScene(new OptionScene());
};
Button buttonUI3 = new Button();
buttonUI3.Name = "buttonCredit";
buttonUI3.Text = "Credit";
buttonUI3.Width = 250;
buttonUI3.Height = 50;
buttonUI3.Alpha = 0.8f;
buttonUI3.SetPosition(dialog.Width/1.5f,dialog.Height - 100);
buttonUI3.TouchEventReceived += (sender, e) => {
Support.SoundSystem.Instance.Play("ButtonClick.wav");
Director.Instance.ReplaceScene(new CreditScene());
};
dialog.AddChildLast(ib);
dialog.AddChildLast(buttonUI1);
dialog.AddChildLast(buttonUI2);
dialog.AddChildLast(buttonUI3);
_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
_uiScene.RootWidget.AddChildLast(dialog);
UISystem.SetScene(_uiScene); // create menu scene
Scheduler.Instance.ScheduleUpdateForTarget(this,0,false); //run the loop
}
示例8: MenuScene
public MenuScene()
{
this.Camera.SetViewFromViewport();
dialog = new Panel();
dialog.Name = "backgroundPanel";
dialog.Width = Director.Instance.GL.Context.GetViewport().Width;
dialog.Height = Director.Instance.GL.Context.GetViewport().Height;
dialog.SetPosition(0,0);
dialog.SetSize(960,544);
dialog.Anchors = Anchors.Top | Anchors.Bottom | Anchors.Left | Anchors.Right;
dialog.Visible = true;
// BUTTON 1
buttonUI1 = new Button();
buttonUI1.Name = "buttonUI1";
buttonUI1.IconImage = null;
buttonUI1.Style = ButtonStyle.Custom;
buttonUI1.SetPosition(dialog.Width/2 - 150,250.0f);
buttonUI1.CustomImage = new CustomButtonImageSettings()
{
BackgroundNormalImage = new ImageAsset("/Application/assets/images/play.png",false),
BackgroundPressedImage = new ImageAsset("/Application/assets/images/playOver.png",false),
BackgroundDisabledImage = new ImageAsset("/Application/assets/images/playOver.png",false),
BackgroundNinePatchMargin = new NinePatchMargin(42, 27, 42, 27),
};
buttonUI1.SetPosition(356, 24);
buttonUI1.SetSize(289, 280);
buttonUI1.Anchors = Anchors.None;
buttonUI1.Visible = true;
buttonUI1.TouchEventReceived += (sender, e) => {
Director.Instance.ReplaceScene(new GameScene( 0 )); // TODO Add support for starting at other levels.
};
// BUTTON 2
buttonUI2 = new Button();
buttonUI2.Name = "buttonMenu";
// buttonUI2
buttonUI2.IconImage = null;
buttonUI2.Style = ButtonStyle.Custom;
buttonUI2.CustomImage = new CustomButtonImageSettings()
{
BackgroundNormalImage = new ImageAsset("/Application/assets/images/instructions.png",false),
BackgroundPressedImage = new ImageAsset("/Application/assets/images/instructionsOver.png",false),
BackgroundDisabledImage = null,
BackgroundNinePatchMargin = new NinePatchMargin(42, 27, 42, 27),
};
buttonUI2.TouchEventReceived += (sender, e) => {
Director.Instance.ReplaceScene(new InstructionsScene());
};
buttonUI2.SetPosition(356, 281);
buttonUI2.SetSize(289, 233);
buttonUI2.Anchors = Anchors.None;
buttonUI2.Visible = true;
dialog.AddChildLast(buttonUI1);
dialog.AddChildLast(buttonUI2);
_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
_uiScene.RootWidget.AddChildLast(dialog);
UISystem.SetScene(_uiScene);
Scheduler.Instance.ScheduleUpdateForTarget(this,0,false);
}
示例9: addUI
private void addUI()
{
Panel panel = new Panel();
panel.Width = Director.Instance.GL.Context.GetViewport().Width;
panel.Height = Director.Instance.GL.Context.GetViewport().Height;
ImageBox backgroundImageBox = new ImageBox();
backgroundImageBox.Width = panel.Width;
backgroundImageBox.Height = panel.Height;
backgroundImageBox.SetPosition(0.0f,0.0f);
backgroundImageBox.Image = new ImageAsset(backgroundImagePath, false);
Button playButton = new Button();
playButton.Name = "Play Game";
playButton.Text = "Play Game";
playButton.Width = 300;
playButton.Height = 50;
playButton.Alpha = 0.8f;
playButton.SetPosition(panel.Width/2 - 150, 200.0f);
playButton.TouchEventReceived += (sender, e) => {
Director.Instance.ReplaceScene(new MainGameScene());
};
panel.AddChildLast(backgroundImageBox);
panel.AddChildLast(playButton);
this.uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
this.uiScene.RootWidget.AddChildLast(panel);
UISystem.SetScene(this.uiScene);
}
示例10: OptionScene
public OptionScene()
{
Console.WriteLine("---- option scene ----");
this.Camera.SetViewFromViewport();
Sce.PlayStation.HighLevel.UI.Panel panel = new Panel();//create panel
panel.Width = Director.Instance.GL.Context.GetViewport().Width;
panel.Height = Director.Instance.GL.Context.GetViewport().Height;
Sce.PlayStation.HighLevel.UI.Label title_label = new Sce.PlayStation.HighLevel.UI.Label();//title label
Sce.PlayStation.HighLevel.UI.Label music_label = new Sce.PlayStation.HighLevel.UI.Label();//music label
Sce.PlayStation.HighLevel.UI.Label sound_label = new Sce.PlayStation.HighLevel.UI.Label();//sound label
labelSetting(title_label, //label name
"Option", //label content
panel.Width/10, //x position
10, //y position
250, //x size
100, //y size
64, //font size
FontStyle.Bold, //font style
new UIColor(0, 255, 0, 255)); //font color
labelSetting(music_label,
"Music :",
panel.Width/7,
panel.Height/5,
150,
100,
32,
FontStyle.Regular,
new UIColor(0, 255, 0, 255));
labelSetting(sound_label,
"Sound :",
panel.Width/7,
panel.Height/3f,
150,
100,
32,
FontStyle.Regular,
new UIColor(0, 255, 0, 255));
Sce.PlayStation.HighLevel.UI.CheckBox checkMusicButton = new CheckBox(); //music
checkMusicButton.Checked = isMusicCheckboxChanged;
checkMusicButton.SetPosition(panel.Width/3,panel.Height/4.5f);
checkMusicButton.SetSize(50,50);
checkMusicButton.CheckedChanged += HandleCheckMusicButtonCheckedChanged;
sliderForMusic = new Sce.PlayStation.HighLevel.UI.Slider();
sliderForMusic.SetPosition(panel.Width/2f,panel.Height/4.5f);
sliderForMusic.SetSize(200,50);
sliderForMusic.MinValue = 0;
sliderForMusic.MaxValue = 1;
sliderForMusic.Value = 0.5f;
sliderForMusic.ValueChanging += HandleSliderForMusicValueChanging;//end music
Sce.PlayStation.HighLevel.UI.CheckBox checkSoundButton = new CheckBox();//sound
checkSoundButton.Checked = isSoundCheckboxChanged;
checkSoundButton.SetPosition(panel.Width/3,panel.Height/2.5f);
checkSoundButton.SetSize(50,50);
checkSoundButton.CheckedChanged += HandleCheckSoundButtonCheckedChanged;
sliderForSound = new Sce.PlayStation.HighLevel.UI.Slider();
sliderForSound.SetPosition(panel.Width/2f,panel.Height/2.5f);
sliderForSound.SetSize(200,50);
sliderForSound.MinValue = 0;
sliderForSound.MaxValue = 1;
sliderForSound.Value = Support.SoundSystem.volumOfSound;
sliderForSound.ValueChanging += HandleSliderForSoundValueChanging;//end sound
Button buttonUI1 = new Button(); //buttons
buttonUI1.Name = "go back";
buttonUI1.Text = "go back";
buttonUI1.Width = 250;
buttonUI1.Height = 50;
buttonUI1.Alpha = 0.8f;
buttonUI1.SetPosition(panel.Width/5,panel.Height - 100);
buttonUI1.TouchEventReceived += (sender, e) => {
Support.SoundSystem.Instance.PlayNoClobber("ButtonClick.wav");
Director.Instance.ReplaceScene(new MenuScene());
};
Button buttonUI2 = new Button();
buttonUI2.Name = "reset";
buttonUI2.Text = "reset";
buttonUI2.Width = 250;
buttonUI2.Height = 50;
buttonUI2.Alpha = 0.8f;
buttonUI2.SetPosition(panel.Width/2f,panel.Height - 100);
buttonUI2.TouchEventReceived += (sender, e) => {
Support.SoundSystem.Instance.PlayNoClobber("ButtonClick.wav");
};
_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
panel.AddChildLast(title_label);//add widgets in panel
panel.AddChildLast(music_label);
panel.AddChildLast(sound_label);
panel.AddChildLast(checkMusicButton);
panel.AddChildLast(checkSoundButton);
//.........这里部分代码省略.........