I am using this code to try to give my ship a physics outline instead of just a square. I am finding it difficult to mix it with my existing collision filter code, the ship no longer collides with enemy lasers like it used to. Where am I going wrong here?
Set drawmode to hybrid and see if the shape is what you think it should be. Outline is not guaranteed to give a perfect body nor will it always match the graphic shape.
You could get and use “Physics editor”. After you get the hang of it it’s really nice to have. There is a 7 day trial.
I found that for small things like ships it’s very easy to use because you can just get the shape code from the other file and use it in your code instead of reading files.
Oh ya i understand. I always get that “Ughhh” feeling when i find a good tool and then find out that i have to pay haha … I can’t really say as iv’e never used graphics.newOutline. Sorry.
All I was saying was that I realized that Corona has a built in function to do the same thing so want want to learn how to use that. The shape that it is drawing seems to be correct enough for me, it is just not detecting collisions anymore.
There is another alternative here. Don’t hand calculate filters. Use my collision calculator instead. Its free and much easier than calculating filters.
Ya sorry @roaminggamer. That was some time ago I did that on my laptop. I built my own pc now and I bought the product like a week ago. When I need something i do buy it now as I do understand that as a developer I get why devs want a small fee for their hard work. --SonicX278
My problem is that Corona completely crashes and closes when I use the actual ship group (which is what I do throughout my code and I get expected results). When I replace the ship group with just the ship’s image (as in the code below, Corona does not crash but there is no collision:
function Ship:new(X, Y) local ship = display.newGroup() ship.x = X ship.y = Y ship.objectType = "ship" ship.health = shipHealth ship.shipLaserGroup = display.newGroup() moveGroup:insert(ship.shipLaserGroup) ship.shipImage = display.newImage(sheet,sheetInfo:getFrameIndex(shipName)) ship.shipImage.xScale = 0.7 ship.shipImage.yScale = 0.7 ship:insert(ship.shipImage) local group = display.newGroup() local particle = pex.load("Exhaust/exhaust.pex","Exhaust/texture.png") local emitter = display.newEmitter(particle) emitter.x = ship.shipImage.x emitter.y = ship.shipImage.y + ship.shipImage.height/2 ship:insert(emitter) local shipOutline = graphics.newOutline( 2, sheet, sheetInfo:getFrameIndex(shipName)) local shipCollisionFilter = { categoryBits = bitTable.ship, maskBits = bitTable.enemyLaser } physics.addBody( ship.shipImage, "static", {filter = shipCollisionFilter, outline = shipOutline}) return ship end
Forums etiquette note - You should only use the quote option to respond to a small part of someone’s post like this:
If you don’t need to quote a specific part of the persons response and you want to address that person in your addition to the forum thread do this:
@persons name,
Say what you want here…
Re-quoting every response just wastes space and is hard tor read with no addition of meaning or context.
To answer your question. Yes, file a bug, but make a very small test bench demonstrating the issue and submit that as a bug. Don’t expect the Corona staff to write the example themselves.
Set drawmode to hybrid and see if the shape is what you think it should be. Outline is not guaranteed to give a perfect body nor will it always match the graphic shape.
You could get and use “Physics editor”. After you get the hang of it it’s really nice to have. There is a 7 day trial.
I found that for small things like ships it’s very easy to use because you can just get the shape code from the other file and use it in your code instead of reading files.
Oh ya i understand. I always get that “Ughhh” feeling when i find a good tool and then find out that i have to pay haha … I can’t really say as iv’e never used graphics.newOutline. Sorry.