is initializing a local variable in mouse move ok?

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
girng
Prole
Posts: 40
Joined: Fri Sep 07, 2018 5:42 am

is initializing a local variable in mouse move ok?

Post by girng »

for example, look at all the new memory addresses it creates. is this normal, bad, ok?
Image



i use it because of my is_overlap function
code:
Image

i'm also trying to get `camera:mousePosition()` to get in my world_pos_obj table's x, and y. how can i do that? i tried:

Code: Select all

local world_pos_obj = { x, y = camera:mousePosition(), width = 1, height = 1}
but i get an error:

Image
girng
Prole
Posts: 40
Joined: Fri Sep 07, 2018 5:42 am

Re: is initializing a local variable in mouse move ok?

Post by girng »

UPDATE OK i fixed it!! :Ddddddddddd

Code: Select all

    local world_pos_obj = { width = 1, height = 1}
    world_pos_obj.x, world_pos_obj.y = camera:mousePosition()
it works =]. so ignore that part please. please focus on just my first question ty
User avatar
Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: is initializing a local variable in mouse move ok?

Post by Ulydev »

I don't think this will have any meaningful impact on performance. As for memory usage, Lua's garbage collector will take care of it, so it's fine.
girng
Prole
Posts: 40
Joined: Fri Sep 07, 2018 5:42 am

Re: is initializing a local variable in mouse move ok?

Post by girng »

Ulydev wrote: Wed Sep 12, 2018 2:48 pm I don't think this will have any meaningful impact on performance. As for memory usage, Lua's garbage collector will take care of it, so it's fine.
thanks for support and information. i feel better =]
Post Reply

Who is online

Users browsing this forum: No registered users and 78 guests