hi everybody,
I am making a platform game and i want to create different enemies, so each enemy created has his own properties in the world.
as a test a have done this.
Here i add 20 enemies
[lua]
-CREATE ENEMIES
local spriteSheet = graphics.newImageSheet(“images/mouseSprite.png”, {width = 70, height = 50, numFrames = 4})
local sequenceData = {
{name = “walkRight”, sheet = spriteSheet, frames = {1,2,3,4}, time = 400, loopCount = 0},
}
local mouse,setup1
for i=1, 20 do
mouse = display.newSprite(spriteSheet, sequenceData)
setup1 = {layer = 6, kind = “imageRect”, locX =locX, locY = 75.72,
levelWidth = 70, levelHeight = 50, offsetX = 0, offsetY = 0 }
mte.addSprite(mouse, setup1)
mouse:setSequence( “walkRight” )
mouse:play()
--mouse.x=192;mouse.y=1150
mouse.speed= 1.5;mouse.name=“mouse”
mouse.allowedMovement=200
mouse.travelled=0
locX=locX+2
print(locX)
end
[/lua]
now at the EnterFrame, i want to move and check the positions,
[lua]
enterframe…
for i=1, 20 do
mte.moveSprite(mouse(i), mouse.speed, 0)
mouse.travelled = mouse.travelled + mouse.speed
if mouse.speed < 0 then
if mouse.xScale < 0 then mouse.xScale = 1 end
else
if mouse.xScale > 0 then mouse.xScale = -1 end
end
if mouse.travelled >= mouse.allowedMovement or mouse.travelled <= -mouse.allowedMovement then
mouse.speed = -mouse.speed
mouse.travelled = 0
end
end
[/lua]
Here i have the problem.When i add the sprite to the mte.world, the other propertiers like “mouse.allowedMovement” or mouse.name" etc that i need to retieve for each sprite were not added, so i can´t get them.
if i add enemies,or coins as an object would be a better way than as Sprites? is there another way easier?
thank you very much
Txarly