//\95`\89æ
this.ownerStage.mainContext.globalAlpha = this.opacity;
this.ownerStage.mainContext.drawImage(this.lastImage, 0, 0, this.size.x, this.size.y);
+ this.ownerStage.mainContext.globalAlpha = 1.0;
//\83R\83\93\83e\83L\83X\83g\95Ï\8a·\8ds\97ñ\82ð\95\9c\8bA
this.ownerStage.mainContext.restore();
}
--- /dev/null
+var FreeItemClass = function(manager, args){
+
+ FreeItemClass.base.apply(this, arguments);
+
+ var img = document.createElement('img');
+ img.src = "images/" + args[0]; //\89æ\91\9c\82Í\89¼
+ this.image = img;
+
+ //\83A\83C\83e\83\80\82ð\8eæ\93¾\82Å\82«\82é\89ñ\90\94\81B-1\82Å\96³\8cÀ
+ this.times = -1;
+
+ //\83A\83C\83e\83\80\82ð\8eæ\93¾\82µ\82½\82Æ\82«\82É\8cÄ\82Î\82ê\82é\83R\81[\83\8b\83o\83b\83N\81B\88ø\90\94\82É\83A\83^\83b\83N\82µ\82Ä\82«\82½\83I\83u\83W\83F\83N\83g\82ª\8ew\92è\82³\82ê\82é
+ //null\82Å\89½\82à\82µ\82È\82¢\83A\83C\83e\83\80\82É\82È\82é
+ this.callback = args[1];
+
+ //\90G\82ê\91±\82¯\82½\82Æ\82«\82É\89½tick\82¨\82«\82É
+ //\82 \81A\88ê\89\9e\81BPCDSL\82©\82ç\8ae\83v\83\8d\83p\83e\83B\82ð\8ew\92è\82·\82é\95û\96@\82ª\82 \82é\82Ì\82Å\88ø\90\94\82É\97p\88Ó\82·\82é\95K\97v\82Í\82 \82è\82Ü\82¹\82ñ\81B
+ this.touchInterval = 100;
+ this.lastTouchedTickCount = -9999;
+
+}.extend(ItemClass, {
+ draw: function(x, y){
+ this.ownerStage.mainContext.globalAlpha = this.opacity;
+ this.ownerStage.mainContext.drawImage(this.image, x, y, 32, 32);
+ this.ownerStage.mainContext.globalAlpha = 1.0;
+ },
+ itemAttacked : function(obj, obj_x, obj_y)
+ {
+ if(this.ownerStage.manager.tickCount - this.lastTouchedTickCount > this.touchInterval)
+ {
+ this.lastTouchedTickCount = this.ownerStage.manager.tickCount;
+ if(this.callback)
+ {
+ this.callback();
+ }
+ }
+ }
+});
\ No newline at end of file
this.isPhantom = true;
}.extend(StageObject, {
+
+
draw: function(x, y){
},
--- /dev/null
+var MessageWidghetClass = function(manager, args)
+{
+ MessageWidghetClass.base.apply(this, arguments);
+
+ this.downKeyPushed = false;
+ this.message = args[0];
+ this.origin = new Point2D(10,240);
+ this.size = new Point2D(620, 230);
+
+ //\89ü\8ds\82ª\93ü\82Á\82Ä\82¢\82é\82Æ\82±\82ë\82Å\88ê\8e\9e\92â\8e~\82µ\81«\83L\81[\82Ì\89\9f\89º\82ð\91Ò\82Â
+
+ this.messageIndex = 0;
+ this.interval = 15;
+ this.intervalCount = 0;
+
+}.extend(WidghetClass, {
+ attached : function(){
+ this.manager.pauseStage(this.tick);
+ },
+ tick : function(){
+ if(!this.manager.keyState.downArrow) this.downKeyPushed = false;
+ if(this.intervalCount >= this.interval)
+ {
+ if(this.message[this.messageIndex] == '\n')
+ {
+ if(!this.downKeyPushed)
+ {
+ if(this.manager.keyState.downArrow)
+ {
+ this.downKeyPushed = true;
+ this.messageIndex++;
+ }
+ }
+ }else
+ {
+ this.messageIndex++;
+ }
+ if(this.messageIndex >= this.message.length)
+ {
+ //\83\81\83b\83Z\81[\83W\82ð\95Â\82¶\82é
+ this.manager.resumeStage();
+ return false;
+ }
+ this.intervalCount = 0;
+ }else
+ {
+ this.intervalCount++;
+ }
+ return true;
+ },
+ draw : function(){
+ this.ownerStage.mainContext.globalAlpha = 0.5;
+ this.ownerStage.mainContext.fillRect(this.origin.x, this.origin.y, this.size.x, this.size.y);
+
+ var lineHead = 0;
+ var lines = [];
+ var height = 0;
+ for(var index = 0; i <= this.messageIndex; i++)
+ {
+ var siz = this.ownerStage.mainContext.measureText(this.message.slice(lineHead, index - lineHead));
+ if(siz.x > this.size.x){
+ index--;
+ lines.push(this.message.slice(lineHead, index - lineHead));
+ lineHead = index;
+ height += siz.y;
+ }
+ }
+
+ var yloc = this.origin.y + this.size.y - height;
+ for(var line in lines)
+ {
+ var siz = this.ownerStage.mainContext.measureText(line);
+
+ if(yloc > this.origin.y)
+ {
+ drawText(this.ownerStage.mainContext, line, this.origin.x, yloc);
+ }
+
+ yloc += siz.y;
+ }
+
+ this.ownerStage.mainContext.globalAlpha = 1.0;
+ }
+});
--- /dev/null
+var WidghetClass = function(manager, args)
+{
+ this.manager = manager;
+}
+WidghetClass.prototype = {
+
+ attacked: function(){
+ //Widghet\82ª\89æ\96Ê\82É\95\\8e¦\82³\82ê\82½\8e\9e\82Émanager\82É\82æ\82Á\82Ä\8cÄ\82Î\82ê\82é\81B
+ },
+
+ tick : function(){
+
+ //pauseStage()\82³\82ê\82Ä\82¢\82È\82¯\82ê\82Îmanager\82æ\82è\8cÄ\82Î\82ê\82é\81B
+ },
+
+ draw : function(){
+ //manager\82É\82æ\82è\8cÄ\82Î\82ê\82é\81B
+ }
+
+};
this.debugText = document.getElementById('DebugText');
//実行中のGameStageオブジェクトを格納
this.runningStage = null;
+ //現在存在しているWidghetのリストを格納
+ this.runningWidghets = [];
//タイマーカウントを初期化
this.tickCount = 0;
this.timeStamp = 0;
this.debugContext.strokeStyle = "rgb(0, 0, 0)";
this.debugContext.font = "normal 20px sans-serif";
+ // pauseStage()が呼ばれたときにnullじゃなくなる
+ this.stagePausedFunction = null;
+
//**イベントリスナー設定**
//コールバックを行うために、イベントリスナーのmanagerプロパティにGameManagerのインスタンスを代入する。
//keyDown
//****timerTick****
this.tickCount++;
//実行中のステージに通知
+
if(this.runningStage){
- this.runningStage.timerTick();
+ if(this.stagePausedFunction == null)
+ {
+ this.runningStage.timerTick();
+ for(var i = 0; i < this.runningWidghets.length; i++){
+ var w = this.runningWidghets[i];
+ if(!w.tick()){
+ // Widghetのtick()からfalseで帰ってきたらWidghetを開放
+ this.runningWidghets.splice(i, 1);
+ i--;
+ }
+ }
+ }else
+ {
+ this.stagePausedFunction();
+ }
this.runningStage.draw();
+ for(var w in this.runningWidghets){
+ w.draw();
+ }
}
},
timeStampTimerTick: function(){
}
},
+ addWidghet: function(w){
+ w.attached();
+ this.runningWidghets.push(w);
+ },
runStage: function(stage){
//****新たなステージを開始する****
//実行中のステージがあれば終了処理を行わせる。
this.runningStage = stage;
this.calculateFps();
},
+ pauseStage: function(func){
+ //ステージの実行を一時停止する。一時停止中、funcに指定された関数が毎tick毎に呼ばれる
+ if(this.stagePausedFunction == null)
+ {
+ this.stagePausedFunction = func;
+ return true;
+ }else
+ {
+ //ステージが一時停止中のfunc()の中から二重にpauseStage()を呼んではいけない
+ return false;
+ }
+ },
+ resumeStage: function(){
+ if(this.stagePausedFunction != null)
+ {
+ //必ずpauseStage()の引数に指定したfunc()の中から呼ばれる・・・はず。
+ this.stagePausedFunction = null;
+ return true;
+ }else
+ {
+ return false;
+ }
+ },
stopStage: function(){
//****現在実行中のステージを終了する****
if(this.runningStage){
document.write("<script type='text/javascript' src='corelib/classes/HorizonalScrollStageClass.js'></script>");
document.write("<script type='text/javascript' src='corelib/classes/PCDSLStageClass.js'></script>");
document.write("<script type='text/javascript' src='corelib/classes/StageObjectClass.js'></script>");
+document.write("<script type='text/javascript' src='corelib/classes/WidghetClass.js'></script>");
+document.write("<script type='text/javascript' src='corelib/classes/MessageWidghetClass.js'></script>");
document.write("<script type='text/javascript' src='corelib/classes/ItemClass.js'></script>");
document.write("<script type='text/javascript' src='corelib/classes/MessageItemClass.js'></script>");
+document.write("<script type='text/javascript' src='corelib/classes/FreeItemClass.js'></script>");
document.write("<script type='text/javascript' src='corelib/classes/BlockClass.js'></script>");
document.write("<script type='text/javascript' src='corelib/classes/SlopeBlockClass.js'></script>");
document.write("<script type='text/javascript' src='corelib/classes/MovableStageObjectClass.js'></script>");