ios - Class design and delegates -


1) gamescene view have add sknodes scene them viewed has wave manager creates first wave of enemies.

2) wave manager. creates , deletes waves, changes next waves parameters based on previous wave. has reference current wave , can return it.

3) wave class. class creates enemies on timer, has of logic how enemies behave (flocking).

every time create enemy in wave want add gamescene. method adds enemies wave ran on timer based on game clock.

i tried implement delegate pattern every time method called in wave class delegate called in gamescene. problem game scene doesn't have a wave object in when try call method in wave class won't delegate null.

the delegate works when create instance of wave in gamescene call method code executes 1 of methods defined in delegates protocol.

are there other design patterns can follow whenever call method in wave, method or draw function called/updated in gamescene, bearing in mind game scene not know wave objects. can see game manager.

you can pass delegate wave manager , can pass on each wave it's created. delegate pattern 1:1 relationship delegate doesn't have pass directly class requires delegate.

if more things game scene interested in new enemies appearing posting notifications suitable. delegate 1:1, notifications 1:many.

another idea pass game scene parent node of of enemies. if override addchild: in game scene can check each new child , decide do...


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -