This is still a work in progress. I am new to this and would like feedback
This will take a sprite sheet and create individual sprites from it. You can then create animations by selecting what frames to display using the bottom left sprite as 1
Ok i’ve got it. Line 157 you write. Coord = screenCoord
So you think you have copied screen Coord to coord… But no, you have copied the adress of screenCoords to coord: the two are pointing to the same memory location now. A class is a complex object, so the = asignment does not pass the value but the adress. if you want a real copy of the values, you must copy all fields as for variable b in below example:
-- test vec2
function setup()
v = vec2(100,0)
a = v
b = vec2() ; b.x = v.x ; b.y = v.y
print("v = "..tostring(v))
print("a = "..tostring(a))
print("b = "..tostring(b))
v.x = v.x + 100
print("v = "..tostring(v))
print("a = "..tostring(a))
print("b = "..tostring(b))
end
function draw()
end
Check the lua manual for types that are passed by value (numbers,booleans,strings?) everything else is passed as adress. Strings are not really passed as value, the adress is passed, but since in lua you never modify a string, you just create a new one, the result is the same.
You need to write a deepcopy() routine. I have one somewhere…i found it online. It handles tables. I don,t recall if it handles userdata, which is vec2, color, etc.
Thanks aciolino, I had no idea what a deep copy was. Looks like I’ve been doing shallow copies. if you happen to run across you code I would like to see it.
I dont believe I deleted it on purpose. Its a library that has become very messy. I used it in a small game. I have plans on cleaning it up and will repost it.