Hello everybody,
I was wondering how to set a point(with a x,y) in an image, so when the image change your position, the point in the image also changes its position in the same proportionality.
It is possible to do in Löve ? How can i do that ?
[HELP] ImagePoints
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[HELP] ImagePoints
Last edited by gomez on Wed Jan 21, 2015 10:33 pm, edited 2 times in total.
Hey dude
Do you want to protect earth from an apocalypse ? Me too o/
Check my new game here: viewtopic.php?f=5&t=81001
Do you want to protect earth from an apocalypse ? Me too o/
Check my new game here: viewtopic.php?f=5&t=81001
Re: [HELP] ImagePoints
What? I dont understand what you mean, but I guess... Just calculate the position?
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: [HELP] ImagePoints
I'm guessing a simple
would do it. (though this code is indeed unstructured, and a bit ugly because of that )
Code: Select all
-- use somewhere, like in love.load or another function you don't call every frame
img = love.graphics.newImage("whatever.png")
xImg = 100
yImg = 100
-- relative to image - coordinate offsets
oxPoint = 10
oyPoint = 15
-- ...
-- love.draw
love.graphics.draw(img,xImg,yImg)
-- important part
love.graphics.point(xImg+oxPoint,yImg+oyPoint)
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: [HELP] ImagePoints
sorry, i've expressed myself badly ..(damn! google translate ¬¬' )S0lll0s wrote:What? I dont understand what you mean, but I guess... Just calculate the position?
I wanted to create a point in an image (by point, understand something that has x and y coordinates and is relative to a image) and that this point accompany all image movements in which it is; For example, if the image moves up, this point also moves and remains in the same place relatives to the image. If the picture rotates, the point moves along
Something like this, but if the point is on top of an image like a rectangle, and the rectangle rotate aside, the point does not move relatively to the image, it is stopped. I have this problemzorg wrote:I'm guessing a simplewould do it. (though this code is indeed unstructured, and a bit ugly because of that )Code: Select all
-- use somewhere, like in love.load or another function you don't call every frame img = love.graphics.newImage("whatever.png") xImg = 100 yImg = 100 -- relative to image - coordinate offsets oxPoint = 10 oyPoint = 15 -- ... -- love.draw love.graphics.draw(img,xImg,yImg) -- important part love.graphics.point(xImg+oxPoint,yImg+oyPoint)
Hey dude
Do you want to protect earth from an apocalypse ? Me too o/
Check my new game here: viewtopic.php?f=5&t=81001
Do you want to protect earth from an apocalypse ? Me too o/
Check my new game here: viewtopic.php?f=5&t=81001
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: [HELP] ImagePoints
You never mentioned rotation though, but it should work as it is with moving the image by modifying xImg and yImggomez wrote:Something like this, but if the point is on top of an image like a rectangle, and the rectangle rotate aside, the point does not move relatively to the image, it is stopped. I have this problem
Rotation is a bit trickier.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: [HELP] ImagePoints
sorry, I have explained badly my doubt ..zorg wrote: You never mentioned rotation though, but it should work as it is with moving the image by modifying xImg and yImg
Rotation is a bit trickier.
I wanted to make a picture orbit over another image (the two images are circles).. i'll keep trying..
thank you
Hey dude
Do you want to protect earth from an apocalypse ? Me too o/
Check my new game here: viewtopic.php?f=5&t=81001
Do you want to protect earth from an apocalypse ? Me too o/
Check my new game here: viewtopic.php?f=5&t=81001
Re: [HELP] ImagePoints
Pretty easy to do using a (dirty word) canvas.
Re: [HELP] ImagePoints
Like this? The 7th and 8th variable changes where it's drawn from.
https://www.love2d.org/wiki/love.graphics.draw
https://www.love2d.org/wiki/love.graphics.draw
Code: Select all
rotation = 0
apple = love.graphics.newImage("apple.png")
function love.draw( )
rotation = rotation + 0.02
love.graphics.draw(apple,400,300,rotation,1,1,45,200) -- The last 2 variable does what you want(i think).
end
- Attachments
-
- blah.love
- (7.26 KiB) Downloaded 64 times
Artal, A .PSD loader: https://github.com/EvineDev/Artal
Re: [HELP] ImagePoints
This is usually achieved using translation matrices. There's a bit of work to do to implement it on your own, but it's a basic requisite for 2d video games so there are quite a few tutorials out there explaining how to achieve it. https://en.wikipedia.org/wiki/Translati ... eometry%29
As far as I know, the only existing Love functionality that can help with this is in the love.physics module. https://www.love2d.org/wiki/Body:getWorldPoints
But unless you actually need physics support in your game, it makes no sense to start creating bodies and fixtures just so you can use the transformation logic.
As far as I know, the only existing Love functionality that can help with this is in the love.physics module. https://www.love2d.org/wiki/Body:getWorldPoints
But unless you actually need physics support in your game, it makes no sense to start creating bodies and fixtures just so you can use the transformation logic.
Re: [HELP] ImagePoints
I doubt he even needs to calculate it, drawing might be enough already.nfey wrote:This is usually achieved using translation matrices. There's a bit of work to do to implement it on your own, but it's a basic requisite for 2d video games so there are quite a few tutorials out there explaining how to achieve it. https://en.wikipedia.org/wiki/Translati ... eometry%29
As far as I know, the only existing Love functionality that can help with this is in the love.physics module. https://www.love2d.org/wiki/Body:getWorldPoints
But unless you actually need physics support in your game, it makes no sense to start creating bodies and fixtures just so you can use the transformation logic.
Who is online
Users browsing this forum: 9912, Ahrefs [Bot] and 3 guests