mirror of
https://github.com/ysoftdevs/pf2016.git
synced 2026-05-02 13:24:23 +02:00
reafactor teleport pair into one function
This commit is contained in:
@@ -13,3 +13,28 @@ function addRedirector(context, x, y, vectorX, vectorY, imageIndex) {
|
||||
|
||||
context.redirectorGroup.addChild(redirector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new teleport
|
||||
*/
|
||||
function addTeleport(context, x, y, affectedX, affectedY, isForwardAnimation) {
|
||||
var teleport = new Kiwi.GameObjects.Sprite(context, context.textures.teleport, x*64, y*64);
|
||||
if (isForwardAnimation) {
|
||||
teleport.animation.add('idle', [ 0, 1, 2, 3 ], 0.3, true);
|
||||
} else {
|
||||
teleport.animation.add('idle', [ 3, 2, 1, 0 ], 0.3, true);
|
||||
}
|
||||
teleport.animation.play('idle', true);
|
||||
teleport.type = 'teleport';
|
||||
teleport.affectedX = affectedX*64;
|
||||
teleport.affectedY = affectedY*64;
|
||||
context.redirectorGroup.addChild(teleport);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add pair of binded teleports
|
||||
*/
|
||||
function addTeleportPair(context, x, y, x2, y2) {
|
||||
addTeleport(context, x, y, x2, y2, true);
|
||||
addTeleport(context, x2, y2, x, y, false);
|
||||
}
|
||||
Reference in New Issue
Block a user