本文整理汇总了C#中Sprite.SetScale方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.SetScale方法的具体用法?C# Sprite.SetScale怎么用?C# Sprite.SetScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.SetScale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupGorgon
private void SetupGorgon()
{
Gorgon.Initialize(true, false);
Gorgon.SetMode(this);
//Gorgon.AllowBackgroundRendering = true;
//Gorgon.Screen.BackgroundColor = Color.FromArgb(50, 50, 50);
//Gorgon.CurrentClippingViewport = new Viewport(0, 20, Gorgon.Screen.Width, Gorgon.Screen.Height - 20);
//PreciseTimer preciseTimer = new PreciseTimer();
//Gorgon.MinimumFrameTime = PreciseTimer.FpsToMilliseconds(66);
Gorgon.Idle += new FrameEventHandler(Gorgon_Idle);
Gorgon.FrameStatsVisible = true;
bouncesprite = new Sprite("bouncey", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"\textures\0_Items.png"), new Vector2D(0,0), new Vector2D(22,20));
bouncesprite.SetScale(3, 3);
decalsprite = new Sprite("decal", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"\textures\0_Decals.png"), new Vector2D(56,0), new Vector2D(103,29));
decalsprite.SetScale(1, 1);
decalShader = FXShader.FromFile(mediadir + @"\shaders\decalshader.fx", ShaderCompileOptions.Debug);
decalShader.Parameters["tex1"].SetValue(decalsprite.Image);
baseTarget = new RenderImage("baseTarget", 32, 32, ImageBufferFormats.BufferRGB888A8);
baseTargetSprite = new Sprite("baseTargetSprite", baseTarget);
bounceysprites = new BounceySprite[10];
for (int i = 0; i < 10; i++)
{
bounceysprites[i] = new BounceySprite(bouncesprite, new Vector2D(random.Next(0, Gorgon.Screen.Width), random.Next(0, Gorgon.Screen.Height)),
new Vector2D((float)random.Next(-100000,100000) / 100000, (float)random.Next(-100000,100000) / 100000),
decalsprite, new Vector2D(random.Next(-10,15), random.Next(-10,15)), decalShader, this);
}
//Calculate decal texcoord offsets
/*Vector2D decalBToffset = new Vector2D(10,5);
float BTXDTL_x = decalBToffset.X / bouncesprite.Image.Width;
float BTXDTL_y = decalBToffset.Y / bouncesprite.Image.Height;
float BTXDBR_x = (decalBToffset.X + decalsprite.Width)/bouncesprite.Image.Width;
float BTXDBR_y = (decalBToffset.Y + decalsprite.Height)/bouncesprite.Image.Height;
float CFx = (float)decalsprite.Image.Width/(float)bouncesprite.Image.Width;
float CFy = (float)decalsprite.Image.Height / (float)bouncesprite.Image.Height;
float DOtc_xtl = (float)decalsprite.ImageOffset.X / (float)decalsprite.Image.Width;
float DOtc_ytl = (float)decalsprite.ImageOffset.Y / (float)decalsprite.Image.Height;
Vector4D decalParms1 = new Vector4D(BTXDTL_x, BTXDTL_y, BTXDBR_x, BTXDBR_y);
Vector4D decalParms2 = new Vector4D(CFx, CFy, DOtc_xtl, DOtc_ytl);*/
}
示例2: CreateSprites
void CreateSprites()
{
var cache = ResourceCache;
var graphics = Graphics;
UI ui = UI;
// Get the Urho3D fish texture
Texture2D decalTex = cache.GetTexture2D("Textures/UrhoDecal.dds");
for (uint i = 0; i < NumSprites; ++i)
{
// Create a new sprite, set it to use the texture
Sprite sprite = new Sprite();
sprite.Texture = decalTex;
// The UI root element is as big as the rendering window, set random position within it
sprite.Position = new IntVector2((int) (NextRandom()*graphics.Width), (int) (NextRandom()*graphics.Height));
// Set sprite size & hotspot in its center
sprite.Size = new IntVector2(128, 128);
sprite.HotSpot = new IntVector2(64, 64);
// Set random rotation in degrees and random scale
sprite.Rotation = NextRandom()*360.0f;
sprite.SetScale(NextRandom(1.0f) + 0.5f);
// Set random color and additive blending mode
sprite.SetColor(new Color(NextRandom(0.5f) + 0.5f, NextRandom(0.5f) + 0.5f, NextRandom(0.5f) + 0.5f));
sprite.BlendMode = BlendMode.Add;
// Add as a child of the root UI element
ui.Root.AddChild(sprite);
// Store sprites to our own container for easy movement update iteration
spritesWithVelocities[sprite] = new Vector2(NextRandom(200.0f) - 100.0f, NextRandom(200.0f) - 100.0f);
}
}
示例3: CreateLogo
void CreateLogo()
{
cache = ResourceCache;
var logoTexture = cache.GetTexture2D("Textures/LogoLarge.png");
if (logoTexture == null)
return;
ui = UI;
logoSprite = ui.Root.CreateSprite();
logoSprite.Texture = logoTexture;
int w = logoTexture.Width;
int h = logoTexture.Height;
logoSprite.SetScale(256.0f / w);
logoSprite.SetSize(w, h);
logoSprite.SetHotSpot(0, h);
logoSprite.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Bottom);
logoSprite.Opacity = 0.75f;
logoSprite.Priority = -100;
}