I have posted this previously but although helpful responses It didn’t answer my question.
I am really stumped on this one and having read,searched the internet and used the #corona ICQ channel for what seems like days I have got no further.
Maybe this just cant be done but it seems very unlikely.
Anyway to the question:
I have a grid formation of images, think space invaders style.
I have 5 columns and 11 rows, each row displays a different object(image).
The images are put on screen using a loop.
The images move across the screen using an enterFrame listener.
I have 2 options either would do the job, option 2 preferred, however option 1 would be fine also.
- I want to change the images every 10 pixels or so for another image then back again after 10 pixels. So 2 images per row.
(think space invaders again)
I can do this but not implement it into the loop.
- A better option would be to change the images for Sprites, I can then adjust the spritesheet data for the animation.
I am confident in the use of Sprite sheets.
I use an external spritesheet for sprite data and require into main lua using the below:
[lua]display.newSprite(mySprites.sheets.spritesheet, mySprites.sequences.spritesheet)[/lua]
[lua]
– enemy.lua –
function enemys:init(xloc, yloc, row )
self.image = display.newImage(“images/enemy”…row…".png" ) – this is where I call my different images –
self.image:setReferencePoint( CenterReferencePoint )
self.image.x = xloc
self.image.y = yloc
self.image.name = “enemy”
self.movement = 0.5
self.leftHit = 0
self.rightHit = 0
self.numberOfWallHits = 0
self.floorHits = 0
end
[/lua]
[lua]
–main.lua–
function createEnemy(x,y,row)
scene = display.newGroup()
allEnemys = {}
local enemys = require(“modules.enemy”)
for j = 1, 5 do
for i = 1, 11 do
allEnemys[#allEnemys + 1] = enemys:new()
allEnemys[#allEnemys]:init(i * 60, j* 70 +70,j ) – this takes care of the placing –
allEnemys[#allEnemys]:start()
end
end
end[/lua]
So anything, any help, any pointers would be gratefully received.
Thank you
