OSDN Git Service

敵が落ちた時に削除されるようにした。
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / MessageWidgetClass.js
1 var MessageWidgetClass = function(manager, args)
2 {
3         MessageWidgetClass.base.apply(this, arguments);
4         
5         this.downKeyPushed = false;
6         this.message = args[0];
7         this.origin = new Point2D(10,240);
8         this.size = new Point2D(620, 230);
9         
10         //\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Â
11         
12         this.messageIndex = 0;
13         this.interval = 5;
14         this.intervalCount = 0;
15         
16         //\82±\82Ì\83\81\83b\83Z\81[\83W\82ª\95\\8e¦\82µ\8fI\82í\82Á\82½\8cã\82É\8eÀ\8ds\82·\82é\83E\83B\83W\83F\83b\83g
17         this.nextWidget = args[1];
18         
19         this.wBox = null;
20         this.isPaused = false;
21         
22 }.extend(WidgetClass, {
23         attach : function(){
24                 
25                 this.wBox = createMessageBox("MessageBoxWidghetMessageBox-" + this.manager.tickCount,
26                                                 this.size.x, this.size.y, this.origin.x, this.origin.y,
27                                                 this.manager.mainArea, undefined, undefined, 5);
28                 var w = this;
29                 this.manager.pauseStage(function()
30                 {
31                         // pauseStage\82É\92¼\90Útick\82ð\90Ý\92u\82·\82é\82Ætick\93à\82Ìthis\82Åmanager\82ª\8eæ\93¾\82³\82ê\82Ä\82µ\82Ü\82¤
32                         return w.tick();
33                 });
34         },
35         detach : function(){
36                 this.manager.mainArea.removeChild(this.wBox);
37         },
38         tick : function(){
39                 if(!this.manager.UIManager.keyState.cursorDown) this.downKeyPushed = false;
40                 if(this.intervalCount >= this.interval)
41                 {
42                         if(this.message[this.messageIndex] == '\n')
43                         {
44                                 if(!this.downKeyPushed)
45                                 {
46                                         if(this.manager.UIManager.keyState.cursorDown)
47                                         {
48                                                 this.downKeyPushed = true;
49                                                 this.messageIndex++;
50                                                 this.isPaused = false;
51                                         }else
52                                         {
53                                                 this.isPaused = true;
54                                         }
55                                 }
56                         }else
57                         {
58                                 this.messageIndex++;
59                                 this.isPaused = false;
60                         }
61                         
62                         if(this.messageIndex >= this.message.length)
63                         {
64                                 //\83\81\83b\83Z\81[\83W\82ð\95Â\82\82é
65                                 this.manager.resumeStage();
66                                 if(this.nextWidget)
67                                 {
68                                         this.manager.addWidget(this.nextWidget);
69                                 }
70                                 return false;
71                         }
72                         this.intervalCount = 0;
73                 }else
74                 {
75                         this.intervalCount++;
76                 }
77                 
78                 if(this.wBox != null)
79                 {
80                         changeMessageBox(this.wBox, this.message.slice(0, this.messageIndex), this.isPaused);
81                 }
82                 return true;
83         },
84         draw : function(){
85         }
86 });