making coin patterns

Firstly how do you know event.object1 is the coin and not event.object2… whats the difference?

With regards to coin detection, i find it to be very strange, I created a lot of these patterns to be scattered throughout the level, and hitting any of them came up with nothing in the collision detection… about 20/30 seconds in to the level all of sudden the detection started to work however in a very strange way as in sometimes it worked and sometimes it didn’t, and if I hit coin1 of pattern 1 then coin1 of pattern 2 would also disappear.

I’m thinking how i’m apply the physics doesn’t work. 

When the coins did detect correctly the alpha did work on them

One more thing… I actually have the collision set on Runtime:addEventListener(‘collision’,onCollision)…

Could this be causing the issue???

The local collision makes sense now so i’ve changed to that instead of Runtime collision, unfortunately it has had no effect on the coins, ive moved them down so my character literally walks through them - absolutely nothing until around 20/30 seconds in to the game, then a few work / few dont - very odd

its event.other.id btw instead of event.object1.id - that seems to be one of the Runtime vs Local things

At this point, you should start simple and then make it more complicated. So, just start by creating one coin and setting it near the character and have it collide. If it’s that works, then you start adding back in more complicated code. Everything you’re doing seems to be fine, so starting small and then getting larger is the best way to tackle this one.

If you look at my earlier code where I run createCoinGroup()…

If i ignore that and just run createCoin() instead, this creates just a single coin on its own… this does work exactly how expected.

its only when I put them in the group the physics seem to play up, even though in debug they do still have a physics square around each one.

I just referred your code (minor changes) :-

local backg = {} local moveY = 10 local moveX = 20 local cellWidth = 34 local cellHeight = 34 local gridGroup = display.newGroup() local function buildBack1() for x = 1, 20 do backg[x] = {} for y = 1, 5 do backg[x][y] = display.newImage(GUI,"coin.png", cellWidth, cellHeight) physics.addBody(backg[x][y],"static",{radius=20}) backg[x][y].myName="coins" backg[x][y].x = x\*cellWidth+moveY backg[x][y].y = y\*cellHeight+moveX backg[x][y].id = ("backg["..x.."]["..y.."]") gridGroup:insert(backg[x][y]) end end end buildBack1() function jet:preCollision( event ) local platform = event.other if platform.myName == "coins" then event.contact.isEnabled = false if coin.isVisible == true then coin.isVisible=false; end print("collided") end end jet:addEventListener( "preCollision" )

there is no collision happening for me to spawn the coins …

I just referred your code (minor changes) :-

local backg = {} local moveY = 10 local moveX = 20 local cellWidth = 34 local cellHeight = 34 local gridGroup = display.newGroup() local function buildBack1() for x = 1, 20 do backg[x] = {} for y = 1, 5 do backg[x][y] = display.newImage(GUI,"coin.png", cellWidth, cellHeight) physics.addBody(backg[x][y],"static",{radius=20}) backg[x][y].myName="coins" backg[x][y].x = x\*cellWidth+moveY backg[x][y].y = y\*cellHeight+moveX backg[x][y].id = ("backg["..x.."]["..y.."]") gridGroup:insert(backg[x][y]) end end end buildBack1() function jet:preCollision( event ) local platform = event.other if platform.myName == "coins" then event.contact.isEnabled = false if coin.isVisible == true then coin.isVisible=false; end print("collided") end end jet:addEventListener( "preCollision" )

there is no collision happening for me to spawn the coins …