OSDN Git Service

collisionMap を無効にできるようにした(aManager.enableStageDebug)
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / HorizonalScrollStageClass.js
1
2 var HorizonalScrollStageClass = function()
3 {
4         HorizonalScrollStageClass.base.apply(this, []);
5
6         this.scrollX = 0;
7         this.scrollMaxX =1280 - 640;    //\83X\83e\81[\83W\82Ì\89¡\82Ì\92·\82³-640
8         
9 }.extend(GameStage, {
10         className: "HorizonalScrollStageClass",
11         timerTick: function(){
12
13                 HorizonalScrollStageClass.base.prototype.timerTick.call(this);
14                 if(this.userControlledCharacter)        this.scrollTo(this.getScrollLocation());
15                 this.eachStageObject(function(f){
16                         f.movingSpeedY -= 1;
17                         return true;
18                 });
19         },
20         
21         // \8eq\83X\83e\81[\83W\82Å\81A\91\80\8dì\92\86\83L\83\83\83\89\88È\8aO\82ð\92\86\90S\82É\8e\9d\82Á\82Ä\82«\82½\82¢\82Æ\82«\82Í\82±\82Ì\8aÖ\90\94\82ð\83I\81[\83o\81[\83\89\83C\83h\82·\82é
22         getScrollLocation: function()
23         {
24                 var pos = 0;
25                 if(this.userControlledCharacter)
26                 {
27                         //pos = this.userControlledCharacter.direction == 0 ? -100 : (this.userControlledCharacter.direction == 1 ? 100 : 0);
28                         return this.userControlledCharacter.origin.x - 320;
29                 }
30                 
31                 return 0;
32         },
33         draw: function()
34         {
35                 this.drawBackground();
36                 
37                 this.drawAsPoint(this.scrollX, 0);
38         },
39         drawBackground: function(){
40                 if(this.background)
41                 {
42                         //\89æ\96Ê\88Ê\92u\82É\8d\87\82í\82¹\82Ä\89æ\91\9c\82ð\83X\83N\83\8d\81[\83\8b\95\\8e¦\82·\82é
43                         var width = this.background.width;
44                         var pos = -((this.scrollX / 2) % width);
45                         for(;pos < 640; pos += width)
46                         {
47                                 this.mainContext.drawImage(this.background, pos, 0, 640, 480);
48                         }
49                 }else
50                 {
51                         //\83L\83\83\83\93\83o\83X\82ð\91S\8fÁ\8b\8e
52                         this.mainContext.clearRect(0, 0, this.mainCanvas.width, this.mainCanvas.height);
53                 }
54                 if(this.collisionMapContext)
55                 {
56                         this.collisionMapContext.clearRect(0, 0, this.collisionMapCanvas.width, this.collisionMapCanvas.height);
57                 }
58         },
59         
60         //\83X\83N\83\8d\81[\83\8b\82µ\82½\82¢\82Æ\82«\82É\81Atick\96\88\82É\8cÄ\82Ô\81B
61         scrollTo: function(x){
62                 this.scrollX += (x - this.scrollX) / 7;
63                 if(this.scrollX > this.scrollMaxX) this.scrollX = this.scrollMaxX;
64                 if(this.scrollX < 0) this.scrollX = 0;
65         }
66 });
67