This repository has been archived by the owner on Jul 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
behavior-template.js
67 lines (54 loc) · 1.99 KB
/
behavior-template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
;(function (root, factory, NULL) {
var BEHAVIOR_GLOBAL_NAME = 'ChangeThis';
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
var Phaser = root.Phaser;
if (Phaser === NULL) {
root[BEHAVIOR_GLOBAL_NAME] = factory();
} else {
Phaser.Behavior = Phaser.Behavior || {};
Phaser.Behavior[BEHAVIOR_GLOBAL_NAME] = factory();
}
}
}(this, function (NULL) {
'use strict';
var Behavior = {
// default settings
options: {
// just examples
opt1: 'value',
opt2: 0,
opt3: [true, 23, 'foo']
},
create: function(object, opts) {
// called when the behavior is ADDED to a game object
},
destroy: function(object, opts) {
// called when the behavior is REMOVED from a game object
},
preUpdate: function(object, opts, game, physicsElapsed) {
// called at the very start of the update cycle,
// before any other subsystems have been updated (including Physics)
},
update: function(object, opts, game, physicsElapsed) {
// called after all the core subsystems (Input, Tweens, Sound, etc)
// and the State have updated, but before the render
},
postUpdate: function(object, opts, game, physicsElapsed) {
// called right after the Behavior.update
},
preRender: function(object, opts, game) {
// called right after the Game Renderer completes, but before the State.render
},
render: function(object, opts, game) {
// called right after the Behavior.preRender
},
postRender: function(object, opts, game) {
// called after the Game Renderer and State.render have run
}
};
return Behavior;
}));