C# SHVDN3 Change or Delete Displayed Sprite
-
The code below draws a sprite on the screen without any issues - it works as expected.
But how can i change the sprite on a keypress (or menu selection) and how can i delete/remove it? I tried setting the variable to null and calling it from a keypress, setting the library and texture name, calling DrawSprite(), but that hung the game at the loading screen. (N.B. I removed all the variables for the scale, rotation, color, position, etc to simplify the code).public static string SpriteLibrary = "john"; public static string SpriteName = "logo"; public SpriteDraw() { KeyDown += Basics_KeyDown; Tick += onTick; Interval = 0; } private void onTick(object sender, EventArgs e) { DrawSprite(); } private void DrawSprite() { if (Function.Call<bool>(Hash.HAS_STREAMED_TEXTURE_DICT_LOADED, SpriteLibrary)) { Function.Call(Hash.DRAW_SPRITE, SpriteLibrary, SpriteName, .09f, .15f, .08f, .28f, 0f, 255, 255, 255, 255); } else { Function.Call(Hash.REQUEST_STREAMED_TEXTURE_DICT, SpriteLibrary, false); } } private void Basics_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.NumPad7) { } } }
-
Something like this?
bool drawSprite = true; string spriteDict = "john"; string spriteName = "logo"; public SpriteDraw() { KeyDown += Basics_KeyDown; Tick += onTick; Interval = 0; } private void onTick(object sender, EventArgs e) { DrawSprite(); } private void DrawSprite() { if (drawSprite) { if (Function.Call<bool>(Hash.HAS_STREAMED_TEXTURE_DICT_LOADED, spriteDict)) { Function.Call(Hash.DRAW_SPRITE, spriteDict, spriteName, .09f, .15f, .08f, .28f, 0f, 255, 255, 255, 255); } else { Function.Call(Hash.REQUEST_STREAMED_TEXTURE_DICT, spriteDict, false); } } } private void Basics_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.NumPad7) { spriteDict = "doe"; spriteName = "title"; } else if (e.KeyCode == Keys.NumPad8) { drawSprite = !drawSprite; } }
-
@Jitnaught Perfect. I struggled with this one. Your help and expertise are once more greatly appreciated.
Will use this to preview images (larger size). Going to adapt it to LemonUI rather than keypress. Thanks!