Hi all,
I’ve been playing with Carona the last couple of days and hit the classic newbie problem with groups and collisions.
I’m hoping to open up discussion so us Newbs can understand Display Groups properly and find the best solution to handle Groups and Collisions.
In Physics Notes/Limitations in the developer Guide
https://docs.coronalabs.com/guide/physics/limitations/index.html
it says
you should not move, scale, or rotate entire display groups independently of each other because of underlying Box2D functionality
Let’s say I have a soccer Player represented by a Knee and a Foot. It could also be a player, bat ball… etc.
The Player is a Display Group.
The foot has collision detection (static physics).
Both the knee and foot are display objects added to the Player display group.
The Player is also added to the main group.
You can ‘drag’ the player to a desired position and then ‘tap’ to kick the foot.
There has to be a ball, right? The ball (dynamic) is a display object added to the mainGroup display group where all ‘game’ objects are located.
I’ve created a test project that you can download to check out the code.
yes I know it’s a tennis ball and not soccer…
and what a terrible kick - still to work through that - but collisions first!
I’ve also added ponywolfs visual monitor so start the ‘game’ (either level 1 or level 2) and hit the ‘p’ key to show the physics ‘hybrid’ display.
This setup shows the classic Newbie (me) problem with groups and collisions. You will see that I have 2 ‘level.lua’ files
level1.lua shows just the boot alone - all works nicely.
level2.lua shows the player group with the boot inserted. Now, even if you move the player away from the ball, the foot still collides with the ball. ie, it’s local value hasn’t changed - Bummer.
So… what is the best way to utilise the power of grouping for the Player and not loose collision detection?
How do I keep the convenience of my display group (player) and get the boot physics to move with the player?
Looking forward to your discussion.
Using Carona 2017.3184 (2017.12.8)
Running in Carona Simulator (OSX)