i want to put 5 images in an x NOT y
and i tried the for and it didnt work
is this how to do it?
and where do i put it the load and draw confuse me still i dont know where to put it???
with the print it worked i got 5 replies but with images didnt! can someone give me an example?
for i= 1 ,5 do
love.graphics.draw(' image','100,100)
end
and i also used the x but still didnt? worked
for loop
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: for loop
Right now you are putting all the images in the same spot. The two numbers after image are the location of the image. So you need to make sure each image is in a different location on the screen by varying the first number you give out (if you want to put them in a horizontal row)
Also, you have to create an image resource, not the word image as a string.
Try something like this:
Also, you have to create an image resource, not the word image as a string.
Try something like this:
Code: Select all
image = love.graphics.newImage( 'image.png' ) -- make sure an image.png exists next to your main.lua
for i = 1, 5 do
love.graphics.draw( image, 50 + 50 * i, 100 )
end
-
- Citizen
- Posts: 54
- Joined: Thu Oct 24, 2013 1:29 am
Re: for loop
Oh.. I see thank you So much Got It..
-
- Citizen
- Posts: 54
- Joined: Thu Oct 24, 2013 1:29 am
Re: for loop+text
Okay what am i doing wrong???
i am trying to make random text appears
did i used random wrong? or whats???
i am trying to make random text appears
did i used random wrong? or whats???
Code: Select all
function love.load()
v ={t1,t2}
t1 =('first text')
t2 =('second text')
end
function love.draw()
for k,v in pairs(v) do
g.setColor(255,255,255,255)
g.print(k,math.random(v),100,100)
end
end
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: for loop+text
Ye got the order wrong:
Code: Select all
function love.load()
t1 =('first text')
t2 =('second text')
v ={t1,t2}
end
Help us help you: attach a .love.
-
- Citizen
- Posts: 54
- Joined: Thu Oct 24, 2013 1:29 am
Re: for loop
the random and graphics.print is right???
all i did was put the text? below instead of above?
cool.. thanks.. hope it works ..
all i did was put the text? below instead of above?
cool.. thanks.. hope it works ..
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: for loop
Actually, no. What happened with your code is, when you write this:elsalvador wrote:the random and graphics.print is right???
all i did was put the text? below instead of above?
cool.. thanks.. hope it works ..
Code: Select all
v ={t1,t2}
In this very table, you insert some other variables named t1 and t2.
But, since t1 and t2 are not defined yet, they are both nil. So,
Code: Select all
v={t1,t2}
Code: Select all
v={nil,nil}
Hence Robin's comment:
.Robin wrote:Ye got the order wrong
So you should have defined tables t1 and t2 first, then insert them into table v.
Re: for loop
nothe random and graphics.print is right???
recommend you to check out
http://www.lua.org/pil/4.3.5.html (for loop)
and
https://www.love2d.org/wiki/love.graphics.print and https://www.love2d.org/wiki/love.math.random
for correct syntax
-
- Citizen
- Posts: 54
- Joined: Thu Oct 24, 2013 1:29 am
Re: for loop
thank you ill read it so i can get it ...
Who is online
Users browsing this forum: Bing [Bot] and 5 guests