Well, some dictionaries lasted the entire game. e.g. I have an array of dictionaries that define what skills a hero has.
Then when they cast the skill, a copy of it is created and sent to the skill manager, which manages the lifecycle of the skill, creation of sprites, counting down timers, applying delayed effects etc. Those copies will last between one update cycle to 10 seconds or so.
I started making ability structs or even classes to handle ability specific conditions, but it got annoying as many abilities were just slightly different. e.g. a fireball vs an arrow. Both are projectiles, but one creates an explosion, and thus has an explosion spec and always plays one sound, the other does direct damage, and plays a specific sound depending on what it hits etc. So it got really annoying to make a new struct AND put the code somewhere to handle the logic for the skill.
So… I just put all the code in one skill manager class, and let everyone send dictionaries with whatever information was needed for that skill. Again, this was lots of floats, sound and art filenames strings, as well as game objects and sprites.
I even handled the sprite life cycles, where the only thing that knew about the sprite was the actual drawing node, and the dictionary of the skill that spawned it. I would then tell the sprite to remove itself from parent, then remove the dictionary from the “active skills”, and everything gets released.
So yeah the retain/release cycle of my Array and Dictionary elements was very important, as I used the dictionary as the only representation of an active skill and all the effects, sounds, game objects, characters, and sprites related to the effect/skill.
I thought about just sticking to __Array and __Dictionary… I dunno, again, I’m all for new & better systems, so I’m willing to put in work if it’s going to be better… Not sure about the better, but I’m sure I can get it to work.
So now I’m trying to wrap my head around cocos:Vector::pushBack vs std::vector::push_back
I understand cocos::Vector::pushBack maintains the obj-c style retain/release paradigm.
So if I use std::vector::push_back( cocos2d::Value ), how is the Value’s lifecycle managed? It has no idea it’s being held onto right? Or does it just adopt the scope of the std::vector it’s in via std::moves (or copies)?
If so, I think I’m pretty happy with the solution of just letting cocos2d::Value objects point at Ref* objects. I just retain/release the Ref* object when I create/delete the cocos2d::Value.
Although I still can’t test any of this because I’m still hundreds of errors from being able to compile my first 3.3 build hahaha damnit =/
I’ve seriously spent the past 3 days on this 2.5 to 3.3 move. Well this and lying fetal position in the shower until the hot water runs out, but mostly this.
Thanks again Steve