[SOLVED] How to dynamically center an object

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
CordCodes
Prole
Posts: 2
Joined: Sun May 07, 2017 1:23 pm

[SOLVED] How to dynamically center an object

Post by CordCodes »

I am new to LÖVE 2D and I am trying to dynamically center it. The forums and documentation I have gone through are not really clear and i sort of need this fast.

Thx, Oliver.
Last edited by CordCodes on Mon May 08, 2017 3:31 pm, edited 1 time in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: How to dynamically center an object

Post by raidho36 »

Grab screen width and height, divide in half - that's the center. Then put your stuff in the center.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to dynamically center an object

Post by zorg »

Images and the like are also positioned to their top-left corner, which is not specific to löve, that's how almost anything works with 2D graphics, by default... so if you want to center things, you might also need to subtract half of the dimensions of your object when positioning it for it to be centered with regards to itself.

(Also congrats Raidho for achieving a "leet" amount of posts :3)
Me and my stuff :3True 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.
CordCodes
Prole
Posts: 2
Joined: Sun May 07, 2017 1:23 pm

Solved

Post by CordCodes »

Thanks everyone, I got it now
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests