一応、回転速度で反転する事は出来る様になりましたが、
if文の条件に角度を指定して反転させるにはどうすればいいのでしょうか?
どうか教えて下さいませ。
以前、トリアコンタンさんから教えて貰いました画像表示スクリプトの現状はこうなっております。
if(muki == 0)の所が改造箇所です。
コード: 全て選択
//
/*
@PluginDesc テスト用プラグイン
@Author Furoshiki
@help
*/
/*
(function() {//トリアコンタン様提供
ImageManager.loadBitmap = function(folder, filename, hue, smooth) {
if (filename) {
var path = folder + encodeURIComponent(filename) + '.png';
var bitmap = this.loadNormalBitmap(path, hue || 0);
bitmap.smooth = smooth;
return bitmap;
} else {
return this.loadEmptyBitmap();
}
};
};
})();
*/(function() {//トリアコンタン様提供
'use strict';
var _Spriteset_Map_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
var mawaru = 0;
Spriteset_Map.prototype.createLowerLayer = function() {
// createLowerLayerの元の処理を呼び出します。
_Spriteset_Map_createLowerLayer.apply(this, arguments);
// 画像を格納する箱を作成します。
this._testSprite = new Sprite();
this._testSprite2 = new Sprite();
this._testSprite3 = new Sprite();
// 箱に実際の画像をロードします。(ピクチャフォルダのファイル名を指定。拡張子不要)
this._testSprite.bitmap = ImageManager.loadPicture('Bat');
//蝙蝠を斜め45度へ傾ける。
this._testSprite.rotation = 45 * Math.PI / 180;
this._testSprite.x = 100;
this._testSprite.y = 200;
this._testSprite.scale.x = 1.5;
this._testSprite.scale.y = 0.5;
// 箱を画面に追加します。
this.addChild(this._testSprite);
// 二つ目の画像を扱う
this._testSprite2.bitmap = ImageManager.loadPicture('Actor1_3');
this._testSprite2.rotation = -45 * Math.PI / 180;
this._testSprite2.x = 500;
this._testSprite2.y = 150;
this._testSprite2.scale.x = -1;
this._testSprite2.scale.y = 1;
// 箱を画面に追加します。
this.addChild(this._testSprite2);
// 三つ目の画像を扱う
this._testSprite3.bitmap = ImageManager.loadPicture('Rat');
this._testSprite3.rotation = 450 * Math.PI / 180;
this._testSprite3.x = 400;
this._testSprite3.y = 150;
this._testSprite3.scale.x = -1;
this._testSprite3.scale.y = 1;
this._testSprite3.anchor.x = -0.5;//中心点を画像の半分*半分にしたい。
this._testSprite3.anchor.y = 0.5;
this._testSprite3.alpha = 0.5;
// 箱を画面に追加します。
this.addChild(this._testSprite3);
// ------ createLowerLayerは「create」と名前の付いているとおり「画像を作る」メソッドです。------
// このメソッドで回転などの動きを付けることはできません。
for(mawaru = 0;mawaru > 100;mawaru++){
this._testSprite3.rotation += 1 * Math.PI / 180;
// ------ addChildは一度だけ行えばOKです。------
//this.addChild(this._testSprite3);
};
};
var _Spriteset_Map_update = Spriteset_Map.prototype.update;
var hayasa = 0;
var muki = 0;
Spriteset_Map.prototype.update = function() {
_Spriteset_Map_update.apply(this, arguments);
// ------ 画像に動きをつけたいときは、updateというメソッドに処理を追加します。------
// updateはフレームごと(1/60秒)に呼び出されるメソッドです。
this._testSprite3.rotation += hayasa * Math.PI / 180;
if (muki == 0){
if (hayasa < 20){
hayasa +=0.1;
}else {
hayasa -=0.1;
muki = 1;
};
} else {
if (hayasa > -20){
hayasa -=0.1;
}else {
hayasa +=0.1;
muki = 0;
};
};
};
})();