public UserShipDrawable(UserShip data) { _sprite = new SFML.Graphics.Sprite(); _userShipData = data; _life = data._life; _sprite.Texture = new SFML.Graphics.Texture(data._shipSprite, new SFML.Graphics.IntRect(10, 10, 32, 32)); _sprite.Position = new SFML.Window.Vector2f(50, 50); }
public GeneralTexture(string texture, Vector2D position) { this.position = position; this.texture = GeneralTextureManager.GetTexture(texture); this.sprite = new SFML.Graphics.Sprite(this.texture); this.sprite.Position = this.position.InternalVector; }
public EnemyShipSprite(EnemyShip data) { _sprite = new SFML.Graphics.Sprite(); _enemyShipData = data; _sprite.Texture = new SFML.Graphics.Texture(data._shipSprite, new SFML.Graphics.IntRect(10, 10, 32, 32)); _sprite.Position = new SFML.Window.Vector2f(100, 0); }
// Initialize stuff that can only be initialized when we have all the data from parsing items. public void Init() { this.texture = new SFML.Graphics.Sprite(new SFML.Graphics.Image(textureLocation)); this.topTexture = new SFML.Graphics.Sprite(new SFML.Graphics.Image(topTextureLocation)); this.texture.Width = 32; this.texture.Height = 32; this.texture.Image.Smooth = false; this.topTexture.Width = 32; this.topTexture.Height = 32; this.topTexture.Image.Smooth = false; }
public override void OnDraw(object window) { if (!DrawEnabled) { return; } Vector3 T; Quaternion R; Vector3 S; Node.GlobalTransform.Decompress (out T, out R, out S); // クォータニオンは指定したのと等価な軸が反対で回転角度[0,180]の回転で返ってくる事がある // ここで回転軸(0,0,-1)のものを(0,0,1)に変換する必要がある var angle = R.Angle; var axis = R.Axis; var dot = Vector3.Dot (axis, new Vector3 (0, 0, 1)); if (dot < 0) { angle = 360 - angle; axis = -axis; } var opacity = Node.Upwards.Aggregate (1.0f, (x, node) => x * node.Opacity); var spr = new SFML.Graphics.Sprite (); spr.Texture = Resource.GetDefaultTexture ().Data; spr.TextureRect = new SFML.Graphics.IntRect (0, 0, (int)radius*2, (int)radius*2); spr.Position = new Vector2f (T.X, T.Y); spr.Scale = new Vector2f (S.X, S.Y); spr.Rotation = angle; spr.Origin = new Vector2f (radius, radius); spr.Color = new Color (255, 255, 255, (byte)(127 * opacity)).ToSFML (); var win = window as SFML.Graphics.RenderWindow; win.Draw (spr); }
private void LoadImageForShader_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.CheckFileExists = true; dlg.DefaultExt = ".png"; dlg.Filter = "Images (.png, .jpg, .gif)|*.png;*.jpg;*.gif"; bool? res = dlg.ShowDialog(); if (res == true) { BitmapImage shaderImage = new BitmapImage(); shaderImage.BeginInit(); shaderImage.UriSource = new Uri(dlg.FileName, UriKind.Absolute); shaderImage.EndInit(); PreShaderImage.Source = shaderImage; lock (ShaderControl.DrawLocked) { if (ShaderSprite != null) ShaderSprite.Dispose(); ShaderSprite = new SFML.Graphics.Sprite(new SFML.Graphics.Texture(dlg.FileName)); if (ShaderControl != null) { ShaderControl.DrawableSprites.Clear(); ShaderControl.DrawableSprites.Add(ShaderSprite); } } /* * BitmapImage AIcon = new BitmapImage(); AIcon.BeginInit(); AIcon.UriSource = new Uri(pathtest + "\\" + path, UriKind.Absolute); AIcon.EndInit(); ItemIcon.Source = AIcon; */ } }