objective c - Game State Implementation Using Protocol And Base Class -
from i've read far, seems objective c not have abstract classes. i'm trying implement game state manager similar apple announced in gamekit (gkstate , gkstatemachine).
my solution far involves creating base state class called basegamestate , adheres protocol i've created called gamestate. each state need gameplay, i'm going subclass basegamestate class. basegamestate class there can subclass , not anything, want state machine work 1 type. class controls state i'm in called gamestatemachine , contain array of objects subclassed basegamestate.
to me, seems horrible solution , i'm wondering if there's standard method doing outside of using gamekit classes (which cannot use because need app target yosemite).
you don't need base class, if doesn't provide implementation. more flexible gives user freedom use different base class or extend existing class implementation of protocol.
just have gamestatemachine store array of object conforming gamestate protocol - id <gamestate>
.
Comments
Post a Comment