Is there an accepted naming scheme for
I'm working on a framework for game development in flash and I'm wondering if there's an accepted naming scheme for the main tick / update method name and a name for the functi开发者_开发百科ons to call before and after?
I can think of:
onPreTick(), onTick() and onPostTick()
onPreFrame(), onFrame(), and onPostFrame()
onPreUpdate(), onUpdate(), and onPostUpdate()
Is there some accepted term for what I'm trying to convey?
For flash using on
before event type names is quite standard practice, though that is not required in AS3. So onFrame
is standard. Instead of pre
and post
you can use before
and after
too. And tick
is also common in game loop. However you can use more specific term in update
. For example, if you are updating only the physics then name it updatePhysics
.
Personally I follow the practice of using on[objectName][eventType] for naming my event handlers, for example:
var loader:Loader = new Loader();
loader.addEventListener(Event.COMPLETE, onLoaderComplete);
loader.load(new URLRequest(url));
function onLoaderComplete(e:Event):void {}
However if I were adding an event listener to an object in its class I would exclude the object name so that its more like on[eventType], for example:
public class CustomLoader extends Loader
{
public function CustomLoader(url:String)
{
this.addEventListener(Event.COMPLETE, onComplete);
this.load(new URLRequest(url));
}
function onComplete(e:Event):void { }
}
精彩评论