rendering.draw_sprite - example of usage?
Posted: Sun Apr 28, 2019 10:49 pm
Hi
I'm exploring the rendering API so a simple example I chose was to draw a image near the player on the ground. I created a mod to hold the image because I needed a place to hold it. I tried using a scenario but it made no difference.
How do I draw a sprite?
This doesn't work:
Do I need to create something like this: (eg in mypictures_0.0.1/data.lua)
This is what I was expecting to work based on having the entry in data.lua
I tried using a scenario for this but that made no difference.
From what I can tell I don't understand how SpritePath works but I'm sure there's something else. The wiki doesn't mention it other than in passing. lua-api does. But I can't figure it out from that description. Do I use "file/image1" for sprite? "file/image1.png"?
Or is this the wrong approach?
I'm exploring the rendering API so a simple example I chose was to draw a image near the player on the ground. I created a mod to hold the image because I needed a place to hold it. I tried using a scenario but it made no difference.
How do I draw a sprite?
This doesn't work:
Code: Select all
rendering.draw_sprite{sprite="file/__mypictures__/graphics/image1.png",
target = player.position,
surface = player.surface,
time_to_live = 60}
Code: Select all
data:extend ( {
{
type = "sprite",
name = "image1",
filename = "__mypictures__/graphics/image1.png",
priority = "extra-high",
flags = {"no-crop" },
width = 213, height = 158
},
Code: Select all
rendering.draw_sprite{sprite="file/image1",
target = player.position,
surface = player.surface,
time_to_live = 60}
From what I can tell I don't understand how SpritePath works but I'm sure there's something else. The wiki doesn't mention it other than in passing. lua-api does. But I can't figure it out from that description. Do I use "file/image1" for sprite? "file/image1.png"?
Or is this the wrong approach?