I have a list of quads for a small kids game. I wanted to know how would be the best way to pull out each variable in the quad and assign it to another variable.
gr, down = love.graphics, love.keyboard.isDown
q_state = 0
q_zero = gr.newQuad(0, 0, 128, 128, img.sprite:getDimensions())
q_one = gr.newQuad(128, 0, 128, 128, img.sprite:getDimensions())
q_one = gr.newQuad(128, 0, 128, 128, img.sprite:getDimensions())
q_two = gr.newQuad(256, 0, 128, 128, img.sprite:getDimensions())
q_three = gr.newQuad(384, 0, 128, 128, img.sprite:getDimensions())
if key == "n" then q_state = q_state + 1 end
if q_state == 0 then q_display = q_zer0 end
if q_state == 1 then q_display = q_one end
-- ---QUESTION????----
-- now how do I get each variable out of q_display so i can use them
gr.draw( img.sprite, q_display, x, y )
local gr, down = love.graphics, love.keyboard.isDown
local spriteDimensions = img.sprite:getDimensions()
local quads = {
gr.newQuad(0,0,128,128,spriteDimensions)
gr.newQuad(128,0,128,128,spriteDimensions)
gr.newQuad(256,0,128,128,spriteDimensions)
gr.newQuad(384,0,128,128,spriteDimensions)
}
local q_state = 0
if (key == "n") then
q_state = q_state + 1
end
gr.draw(img.sprite, quads[1 + q_state % #quads],x,y)
I'm not sure I explained myself very well. I want to get the values of q_display and set them to a variable.
q_display_x, q_display_y, q_display_w ect... this way i can always know how large the quad is I'm displaying. I'm going to use this for hitboxes/mouseovers/ect...