Change all quads in table x position relative to each of the

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
PartyCow
Prole
Posts: 18
Joined: Sat Nov 17, 2012 3:12 pm

Change all quads in table x position relative to each of the

Post by PartyCow »

Hey, I'm trying to add quad's to a table and then move all of them afterwards.

Code: Select all

function addquad(quadsize)
quad = love.graphics.newQuad( 50, 50, 2, quadsize/2,0.0001,0.0001)
table.insert(quadtable,quad)
for i,v in ipairs(quadtable) do
--TODO: Change quad [b]x position[/b] by -2
end
end
Now I can't find anywhere about how to get and change the quad's position from the table.
Also, is there a more optimal way to do this?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Change all quads in table x position relative to each of

Post by Plu »

Something like this? If I understand you correctly.

Code: Select all

function addquad(quadsize)
  quad = love.graphics.newQuad( 50, 50, 2, quadsize/2,0.0001,0.0001)
  table.insert(quadtable,quad)
  for i,v in ipairs(quadtable) do
    -- pull the current values from the quad
    local x, y, w, h = v:getViewport()
    -- reinsert the new values with a slightly lower X
    v:setViewport( x-2, y, w, h )
  end
end
PartyCow
Prole
Posts: 18
Joined: Sat Nov 17, 2012 3:12 pm

Re: Change all quads in table x position relative to each of

Post by PartyCow »

Plu yeah just what I needed. Didn't know it was called viewport.
Thanks!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 0 guests