Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BUDSPRITES.LUA
- local sheets = {}
- local sequences = {}
- -- Attach them to our module
- --
- public.sheets = sheets
- public.sequences = sequences
- sheets.invaders = {}
- public.createSpriteStuff = function()
- local sheetData = {
- width = 53, --the width of each frame
- height = 38, --the height of each frame
- numFrames = 2, --the total number of frames on the sheet
- }
- _G.myvalue = myvalue
- local i
- for i=1,5 do
- sheets.invaders[i] = graphics.newImageSheet("images/sprite"..i..".png", sheetData )
- if
- i == 1 then
- myvalue =100
- elseif
- i == 2 then
- myvalue = 200
- elseif
- i == 3 then
- myvalue = 300
- elseif
- i == 4 then
- myvalue = 400
- elseif
- i == 5 then
- myvalue = 500
- end
- end
- sequences.normRun =
- {
- name = "normalRun",
- start = 1,
- count = 2,
- time = 1710,
- loopCount = 0,
- loopDirection = "forward"
- }
- MAIN.LUA
- function createInvader(xloc, yloc, row, myvalue)
- scene = display.newGroup()
- if levelDrop > 350 then
- levelDrop = 350
- end
- for j = 1, 5 do
- for i = 1, 11 do
- allEnemys[#allEnemys + 1] = enemys:new()
- allEnemys[#allEnemys]:init(i * 60, j * 70 + levelDrop, j) --spacing horizontal--spacing vertical -- top screen spacing
- allEnemys[#allEnemys]:start()
- end
- end
- end
- ENEMY.LUA
- function enemys:init(xloc, yloc, row, myvalue )
- self.image = display.newSprite(budSprites.sheets.invaders[row], budSprites.sequences.normRun)
- self.image:setReferencePoint( CenterReferencePoint )
- self.image.x = xloc
- self.image.y = yloc
- self.myvalue = myvalue
- self.image.name = "enemy"
- self.movement = 0.5
- self.leftHit = 0
- self.rightHit = 0
- self.numberOfWallHits = 0
- self.floorHits = 0
- self.image:play()
- local enemyCollisionFilter = { categoryBits = 64, maskBits = 111}
- physics.addBody( self.image, {isSensor = true, filter = enemyCollisionFilter})
- bgmChan1 = audio.play(bgm1,{channel=9, loops = -1})
- end
- --SCORING IN ENEMY.LUA
- local currentScore = getScores( )
- currentScore = currentScore + myvalue
- setScores( currentScore )
Advertisement
Add Comment
Please, Sign In to add comment