Saving player drawing to variable and using it later?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Saving player drawing to variable and using it later?
Hey. I'm making a game (something new...) and I want the player to be able to draw his own player image. I know they can draw penises and other stuff like that but I want to give the player freedom, anyway. How can I get the player drawing to save to a variable (ImageData perhaps?) and then drawing it to the screen? Like a normal image? I know how to make a 2d array and then modify the different parts of the array to edit the picture, then draw it based on the array, but how can I save it to a variable and then use it like a normal image? Hope this isn't too too confusing. Thanks in advance!
Hey.
- SimonLarsen
- Party member
- Posts: 100
- Joined: Thu Mar 31, 2011 4:47 pm
- Location: Denmark
- Contact:
Re: Saving player drawing to variable and using it later?
You can have the player draw to a Canvas.
Then when you want to save the data to a file, you can get the ImageData from the canvas and save it to a file with the encode function:
You can then load this drawing as any other image like you need it.
Then when you want to save the data to a file, you can get the ImageData from the canvas and save it to a file with the encode function:
Code: Select all
local data = canvas:getImageData()
data:encode("drawing.png")
Re: Saving player drawing to variable and using it later?
look up Canvas on the löve wikikxait wrote:Hey. I'm making a game (something new...) and I want the player to be able to draw his own player image. I know they can draw penises and other stuff like that but I want to give the player freedom, anyway. How can I get the player drawing to save to a variable (ImageData perhaps?) and then drawing it to the screen? Like a normal image? I know how to make a 2d array and then modify the different parts of the array to edit the picture, then draw it based on the array, but how can I save it to a variable and then use it like a normal image? Hope this isn't too too confusing. Thanks in advance!
Who is online
Users browsing this forum: Bing [Bot] and 10 guests