Skip to content

Instantly share code, notes, and snippets.

@shtrih
Last active August 29, 2015 13:59
Show Gist options
  • Save shtrih/10571050 to your computer and use it in GitHub Desktop.
Save shtrih/10571050 to your computer and use it in GitHub Desktop.
private function moveOrin():Void
{
_orinPos.unshift(new FlxPoint(_orin.x, _orin.y));
if (_orinPos.length >= _orinTrain.members.length)
{
_orinPos.pop();
}
var current_anim_name = _orin.animation.name;
var offset = { x: _orin.x, y: _orin.y };
switch (_orin.facing)
{
case FlxObject.LEFT:
//_orin.x -= _cellSize;
_orin.animation.play("left");
offset.x = _orin.x - _cellSize;
case FlxObject.RIGHT:
//_orin.x += _cellSize;
_orin.animation.play("right");
offset.x = _orin.x + _cellSize;
case FlxObject.UP:
//_orin.y -= _cellSize;
_orin.animation.play("up");
offset.y = _orin.y - _cellSize;
case FlxObject.DOWN:
//_orin.y += _cellSize;
_orin.animation.play("down");
offset.y = _orin.y + _cellSize;
}
//_orin.x = offset.x;
//_orin.y = offset.y;
//FlxSpriteUtil.screenWrap(_orin);
/*FlxTween.linearMotion(_orin, _orin.x, _orin.y, offset.x , offset.y, _motion_time, true, { type: FlxTween.ONESHOT, complete: {
Lib.trace('screenWrap '+_orin.x+' '+_orin.y);
FlxSpriteUtil.screenWrap(_orin);
if (_orin.x >= 1000) {
_orin.x = 0;
Lib.trace('_orin.x = 0');
}
null;
}});*/
// Вот так правильно
FlxTween.linearMotion(_orin, _orin.x, _orin.y, offset.x , offset.y, _motion_time, true, {
type: FlxTween.ONESHOT,
complete: function (tween: FlxTween): Void {
FlxSpriteUtil.screenWrap(_orin);
}
});
for (i in 0..._orinPos.length)
{
var ghost:FlxObject = cast _orinTrain.members[i];
if ( ghost != null)
{
//ghost.setPosition(_orinPos[i].x, _orinPos[i].y);
FlxTween.linearMotion(ghost, ghost.x, ghost.y, _orinPos[i].x, _orinPos[i].y, _motion_time, true, {type: FlxTween.ONESHOT});
}
}
/*if ( _orin.x <0 || _orin.x > FlxG.width
|| _orin.y <0 || _orin.y > FlxG.height)
{
gameOver(null, null);
}*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment