/** * Call this function to give this object a path to follow. * If the path does not have at least one node in it, this function * will log a warning message and return. * * @param Path The <code>FlxPath</code> you want this object to follow. * @param Speed How fast to travel along the path in pixels per second. * @param Mode Optional, controls the behavior of the object following the path using the path behavior constants. Can use multiple flags at once, for example PATH_YOYO|PATH_HORIZONTAL_ONLY will make an object move back and forth along the X axis of the path only. * @param AutoRotate Automatically point the object toward the next node. Assumes the graphic is pointing upward. Default behavior is false, or no automatic rotation. */ public void followPath(FlxPath Path, float Speed = 100, uint Mode = PATH_FORWARD, bool AutoRotate = false) { if (Path.nodes.Count <= 0) { FlxG.log("WARNING: Paths need at least one node in them to be followed."); return; } path = Path; pathSpeed = FlxU.abs(Speed); _pathMode = Mode; _pathRotate = AutoRotate; //get starting node if ((_pathMode == PATH_BACKWARD) || (_pathMode == PATH_LOOP_BACKWARD)) { _pathNodeIndex = path.nodes.Count - 1; _pathInc = -1; } else { _pathNodeIndex = 0; _pathInc = 1; } }
public void play(String AnimName, Boolean Force = false) { if (!Force && (_curAnim != null) && (AnimName == _curAnim.name) && (_curAnim.looped || !finished)) { return; } _curFrame = 0; _curIndex = 0; _frameTimer = 0; uint i = 0; uint l = (uint)_animations.Count; while (i < l) { if (_animations[(int)i].name == AnimName) { _curAnim = _animations[(int)i]; if (_curAnim.delay <= 0) { finished = true; } else { finished = false; } _curIndex = _curAnim.frames[_curFrame]; dirty = true; return; } i++; } FlxG.log("WARNING: No animation called \"" + AnimName + "\""); }
static private FlxSound loadSound(SoundEffect EmbeddedSound, float Volume, bool Looped, bool AutoDestroy, bool AutoPlay) { if (EmbeddedSound == null) { FlxG.log("WARNING: FlxG.loadSound() requires an embedded sound to work."); return(null); } FlxSound sound = new FlxSound(); if (EmbeddedSound != null) { sound.loadEmbedded(EmbeddedSound, Looped, AutoDestroy); } sound.volume = Volume; if (AutoPlay) { sound.play(); } return(sound); }