Problems when using world callbacks[Solved]

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.
User avatar
NoreoAlles
Party member
Posts: 107
Joined: Mon Jan 03, 2022 5:42 pm

Re: Problems when using world callbacks[Solved]

Post by NoreoAlles »

pgimeno wrote: Sat Jan 08, 2022 10:56 am You don't know which of a or b is going to be the player and which is going to be the platform. You need to check both, but you only check b.

Also, which one is the fixture? self.fixture or self.physics.fixture?
self.physics.fixture and now i corrected the check for b to also be self.physics.fixture
"Why do they call it oven when you of in the cold food of out hot eat the food?" - Jon Arbuckle
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Problems when using world callbacks[Solved]

Post by pgimeno »

As for the confusion between class and instance, as things are now you can't define e.g. two players, because you only have one table with both the method definitions and the instance data. Imagine you do the same with enemies; you could only have one enemy.

I may be wrong because I don't see your whole project, and it's possible that you've used a local Player variable for the class in player.lua and a local Player variable for the instance in main.lua or elsewhere. If that's the case, the only problem is that your naming convention confused me. But if you use Player for both the class and the instance, then the way you've defined things, you can't have more than one player.

A class is like a type, it defines how the variables of that type should behave. An instance (also called object) is like a variable of that type. So you typically define a class and then as many instances as you need. For a single player game, that would be just one player, but for enemies there are typically an enemy class and as many enemy instances, one per enemy.

Edit (per your edit): Are you checking `a` as well?
User avatar
NoreoAlles
Party member
Posts: 107
Joined: Mon Jan 03, 2022 5:42 pm

Re: Problems when using world callbacks[Solved]

Post by NoreoAlles »

pgimeno wrote: Sat Jan 08, 2022 11:06 am Edit (per your edit): Are you checking `a` as well?
hell, i didnt. It now works flawless. I only checked for b :P ...
and about me only being able to have one player, i am starting to programm with courses on YT (not completly copying) and all that refactoring to OOP is brought up in the last episode i think. Also, i already have a Coin in the game, wich is done by metatables and some witchcrafty for loops.
"Why do they call it oven when you of in the cold food of out hot eat the food?" - Jon Arbuckle
Post Reply

Who is online

Users browsing this forum: Bing [Bot], glass2d, MrFariator, Semrush [Bot] and 90 guests