Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TABLE.createCoin(posX, posY)
- local data = require("assets.sprites.coin")
- local map = graphics.newImageSheet("assets/sprites/coin.png", data:getSheet() )
- local animations = {
- {name="idle", start=1, count=3, time=200, loopCount = 0, loopDirection = "forward"},
- }
- local coin = display.newSprite( map , animations )
- elements_group:insert(coin)
- coin.x = posY; coin.y = posY
- coin.lock = false
- physics.addBody(coin, "static")
- coin.isSensor = true
- coin:setSequence("idle")
- coin:play()
- local function coinCollision(event)
- if event.other.type == "player" and event.target.lock == false then
- event.target.lock = true
- display.remove(event.target)
- _G.player.ammo = _G.player.ammo + 1
- ammo.text = _G.player.ammo
- end
- end
- coin:addEventListener("collision", coinCollision)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement