Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Experiences with GameDevHelpers and Gideros? — Gideros Forum

Experiences with GameDevHelpers and Gideros?

zer0flagzer0flag Member
edited August 2013 in General questions
Hey there,

I'm working on a game with gideros + SH/LH/CH and my project is getting bigger and bigger. As always while learning new frameworks/languages I need some refactoring during development :)

Right now I'm about changing the way of loading user defined classes from a level but I'm not sure what's the best practice because my code is getting unclear:

Let's say you have a level loaded with a player and a enemy:

game.lua
...
self.loader = LevelHelperLoader:initWithContentOfFile("level" .. self.currentLevel .. ".plhs");
...
self.player = Player.new(self);
self.enemy = Enemy.new(self);
...
player.lua
Player = gideros.class(Sprite);
function Player:init(game)
end
 
function Player:myFunc()
  print("myFunc() called");
end
enemy.lua
Enemy = gideros.class(Sprite);
function Enemy:init(game)
end
 
function Enemy:dead()
  print("enemy dead");
end
The problem is, that my Player class is not associated with the class in the level file. Then i tried to set all properties from the sprite of the levelfile in the init method but that looks (and sounds to me) very wrong :D (and doesn't work for animation either)
Player = gideros.class(Sprite);
function Player:init(game)
    -- Extend instance with player instance
    self.sprite = game.loader:spriteWithUniqueName("player")
    for key, value in pairs (self.sprite) do
        self[key] = value
    end
end
I know there's a custom class in the LHSprite class but I have no ideas how to use this in a good OOP way. Any ideas?

Thanks in advance from a newbie :)

Comments

Sign In or Register to comment.