MCPcopy Index your code
hub / github.com/phaserjs/phaser / BuildGameObjectAnimation

Function BuildGameObjectAnimation

src/gameobjects/BuildGameObjectAnimation.js:28–97  ·  view source on GitHub ↗
(sprite, config)

Source from the content-addressed store, hash-verified

26 * @return {Phaser.GameObjects.Sprite} The updated Sprite.
27 */
28var BuildGameObjectAnimation = function (sprite, config)
29{
30 var animConfig = GetAdvancedValue(config, 'anims', null);
31
32 if (animConfig === null)
33 {
34 return sprite;
35 }
36
37 if (typeof animConfig === 'string')
38 {
39 // { anims: 'key' }
40 sprite.anims.play(animConfig);
41 }
42 else if (typeof animConfig === 'object')
43 {
44 // { anims: {
45 // key: string
46 // startFrame: [string|number]
47 // delay: [float]
48 // repeat: [integer]
49 // repeatDelay: [float]
50 // yoyo: [boolean]
51 // play: [boolean]
52 // delayedPlay: [boolean]
53 // }
54 // }
55
56 var anims = sprite.anims;
57
58 var key = GetAdvancedValue(animConfig, 'key', undefined);
59
60 if (key)
61 {
62 var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined);
63
64 var delay = GetAdvancedValue(animConfig, 'delay', 0);
65 var repeat = GetAdvancedValue(animConfig, 'repeat', 0);
66 var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0);
67 var yoyo = GetAdvancedValue(animConfig, 'yoyo', false);
68
69 var play = GetAdvancedValue(animConfig, 'play', false);
70 var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0);
71
72 var playConfig = {
73 key: key,
74 delay: delay,
75 repeat: repeat,
76 repeatDelay: repeatDelay,
77 yoyo: yoyo,
78 startFrame: startFrame
79 };
80
81 if (play)
82 {
83 anims.play(playConfig);
84 }
85 else if (delayedPlay > 0)

Callers 2

SpriteCreator.jsFile · 0.85

Calls 1

GetAdvancedValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…