raingame
Version:
2D game framework
19 lines (18 loc) • 743 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.gradullyMoveActions = void 0;
function gradullyMoveActions(options, me) {
if (options.duration) {
var times_1 = options.duration * 60, nowTime_1 = 0;
var verticeX_1 = (options.position.x - me.position.x) / times_1;
var verticeY_1 = (options.position.y - me.position.y) / times_1;
var timer_1 = setInterval(function () {
me.position.x += verticeX_1;
me.position.y += verticeY_1;
nowTime_1++;
if (nowTime_1 >= times_1)
clearInterval(timer_1);
}, options.duration / times_1);
}
}
exports.gradullyMoveActions = gradullyMoveActions;