Skip to content

Instantly share code, notes, and snippets.

@teramotodaiki
Last active June 6, 2016 09:34
Show Gist options
  • Save teramotodaiki/bb0bacb4a24a712fe242aa5c5b6d6ef3 to your computer and use it in GitHub Desktop.
Save teramotodaiki/bb0bacb4a24a712fe242aa5c5b6d6ef3 to your computer and use it in GitHub Desktop.
// ワープ
var warp = new MapObject('warp');
warp.locate(7, 8, 'map1');
warp.layer = RPGMap.Layer.Under;
warp.onplayerenter = function () {
Hack.player.locate(11, 5);
};
warp.isKinematic = false;
warp.ontriggerenter = function (event) {
// event.hit ... 接触したもの
// onbecomeidle ... 歩きが止まった瞬間に
var tmp = event.hit.onbecomeidle;
event.hit.onbecomeidle = function () {
// this ... ここではwarpに触れたモノのこと
if (this === Hack.player) {
// プレイヤーなら…
} else {
// プレイヤー以外なら…
}
// this.locate(10, 5);
this.onbecomeidle = tmp || function () {};
this.onbecomeidle();
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment