Hello everyone. First of all I want to thanks in advance for the help you are giving me. I searched a lot to try to fix my problem, so I decided that maybe I should post it here.
I have been creating a 2d scroller and the controllers for the main character are working pretty well.
My problem lies on the enemy class.
When I create an enemy, it stays as a child of the back ground (it follows background.x when I call the function monster:move())
But whenever I create a second or third enemy, only the first enemy to be created follows the background, and the others remain static on the screen.
I think the problem is because of the enemyImage, which is the same for all the enemies I create, right?
Is there a way I can create separated image objects for every new monster I create on my main class?
--Monster Class local monster = {} local monster\_mt = { \_\_index = monster } local main = require("main") function monster.new(x, y) monsterImage = display.newImage("images/monster.png") monsterImage.x = x monsterImage.y = y local newMonster = { x = x or 0, y = y or 0 } return setmetatable( newMonster, monster\_mt) end function monster:move() monsterImage.x = self.x + background.x end return monster
Here is a video explaining my problem.
http://www.youtube.com/watch?v=s8mTD6xs_3M&feature=youtu.be
THANK YOU VERY MUCH.
Greetings from Chile.