1 TTweet = enchant.Class.create(enchant.Sprite, {
2 initialize : function(yukkuri, w, h) {
5 this.yukkuri = yukkuri;
7 enchant.Sprite.call(this, w, h + TTweet.TAIL);
8 this.image = new Surface(w, h + TTweet.TAIL);
19 lt : {x: 0+s, y: t+s},
20 rt : {x: w-s, y: t+s},
21 rd : {x: w-s, y:h+t-s},
22 ld : {x: 0+s, y:h+t-s}
24 this.image.context.font = "12px 'Times New Roman'";
26 this.addEventListener('enterframe', function(){
27 if((this.age % 15) == 0){
30 if(this.lifetime <= 0){
34 this.x = self.yukkuri.getX() - self.width/4 - self.yukkuri.getWidth() / 2;
35 this.y = self.yukkuri.getY() - self.height - self.yukkuri.getHeight() / 2;
36 // this._tweet.text(text, this.getX() - this._tweet.width/4, this.getY() - this._tweet.height);
41 var o = this.outCurve;
42 with(this.image.context) {
44 strokeStyle = 'black';
46 moveTo(o.lt.x, o.lt.y+c);
47 quadraticCurveTo(o.lt.x, o.lt.y, o.lt.x+c, o.lt.y);
48 lineTo(o.rt.x-c, o.rt.y);
49 quadraticCurveTo(o.rt.x, o.rt.y, o.rt.x, o.rt.y+c);
50 lineTo(o.rd.x, o.rd.y-c);
51 quadraticCurveTo(o.rd.x, o.rd.y, o.rd.x-c, o.rd.y);
52 lineTo(o.ld.x+c, o.ld.y);
53 quadraticCurveTo(o.ld.x, o.ld.y, o.ld.x, o.ld.y-c);
56 // lineTo(this.width/2-4,_height + TTweet.TAIL);
57 // lineTo(this.width/2,_height + 0);
58 // lineTo(this.width/2+4,_height + TTweet.TAIL);
67 var o = this.outCurve;
69 with(this.image.context) {
73 moveTo(i.lt.x, o.lt.y+c);
74 quadraticCurveTo(i.lt.x, i.lt.y, o.lt.x+c, i.lt.y);
75 lineTo(o.rt.x-c, i.rt.y);
76 quadraticCurveTo(i.rt.x, i.rt.y, i.rt.x, o.rt.y+c);
77 lineTo(i.rd.x, o.rd.y-c);
78 quadraticCurveTo(i.rd.x, i.rd.y, o.rd.x-c, i.rd.y);
79 lineTo(o.ld.x+c, i.ld.y);
80 quadraticCurveTo(i.ld.x, i.ld.y, i.ld.x, o.ld.y-c);
85 text : function(text, x, y) {
86 this.x = this.yukkuri.getX() - this.width/4 - this.yukkuri.getWidth() / 2;
87 this.y = this.yukkuri.getY() - this.height - this.yukkuri.getHeight() / 2;
94 with(this.image.context) {
97 textBaseline = 'middle';
100 var textList = text.split("\n");
101 var len = textList.length / 2;
102 var height = (this.height/(1 + len));
103 this.fillTextLine(text,this.width/2, height);
108 fillTextLine : function(text, x, y) {
109 var textList = text.split("\n");
110 var lineHeight = this.image.context.measureText("あ").width + 2;
112 textList.forEach(function(text, i) {
113 self.image.context.fillText(text, x, y + lineHeight * i);
124 var Box = enchant.Class.create(enchant.Sprite, {
125 initialize : function(ctl, node, x, y, w, h) {
126 enchant.Sprite.call(this, w, h + TTweet.TAIL);
136 ctl.game.rootScene.addEventListener('touchstart', this.touchstart(this));
137 ctl.backgroundMap.addChild(this);
141 this.image = new Surface(w, h + TTweet.TAIL);
144 var c = TTweet.CURVE;
152 lt : {x: 0+s, y: t+s},
153 rt : {x: w-s, y: t+s},
154 rd : {x: w-s, y:h+t-s},
155 ld : {x: 0+s, y:h+t-s}
157 this.image.context.font = "12px 'Times New Roman'";
159 this.addEventListener('enterframe', function(){
160 if((this.age % BASE_FPS) == 0){
164 if(this.lifetime <= 0){
167 this.removeEventListener('enterframe', arguments.callee);
172 reDraw : function() {
173 var c = TTweet.CURVE;
174 var o = this.outCurve;
175 with(this.image.context) {
178 strokeStyle = 'black';
180 moveTo(o.lt.x, o.lt.y+c);
181 quadraticCurveTo(o.lt.x, o.lt.y, o.lt.x+c, o.lt.y);
182 lineTo(o.rt.x-c, o.rt.y);
183 quadraticCurveTo(o.rt.x, o.rt.y, o.rt.x, o.rt.y+c);
184 lineTo(o.rd.x, o.rd.y-c);
185 quadraticCurveTo(o.rd.x, o.rd.y, o.rd.x-c, o.rd.y);
186 lineTo(o.ld.x+c, o.ld.y);
187 quadraticCurveTo(o.ld.x, o.ld.y, o.ld.x, o.ld.y-c);
195 var c = TTweet.CURVE;
196 var o = this.outCurve;
197 var i = this.inCurve;
198 with(this.image.context) {
202 moveTo(i.lt.x, o.lt.y+c);
203 quadraticCurveTo(i.lt.x, i.lt.y, o.lt.x+c, i.lt.y);
204 lineTo(o.rt.x-c, i.rt.y);
205 quadraticCurveTo(i.rt.x, i.rt.y, i.rt.x, o.rt.y+c);
206 lineTo(i.rd.x, o.rd.y-c);
207 quadraticCurveTo(i.rd.x, i.rd.y, o.rd.x-c, i.rd.y);
208 lineTo(o.ld.x+c, i.ld.y);
209 quadraticCurveTo(i.ld.x, i.ld.y, i.ld.x, o.ld.y-c);
214 drawBox : function() {
217 text = this.node.getStatusForDisplay();
219 with(this.image.context) {
221 textAlign = 'center';
222 textBaseline = 'middle';
223 var textList = text.split("\n");
224 var len = textList.length / 2;
225 var height = (this.height/(1 + len));
226 this.fillTextLine(text,this.width/2, height);
229 fillTextLine : function(text, x, y) {
230 var textList = text.split("\n");
231 var lineHeight = this.image.context.measureText("あ").width + 2;
233 textList.forEach(function(text, i) {
234 self.image.context.fillText(text, x, y + lineHeight * i);
243 getWidth: function(){
246 getHeight: function(){
249 touchstart:function(self){
251 if(typeof e === "undefined")return;
252 // this.removeEventListener('touchstart', arguments.callee);
254 // if(self.x <= e.x && self.x + self.width >= e.x
255 // && self.y <= e.y && self.y + self.height >= e.y
257 if(ctl.isCollision(e, self)){
258 this.removeEventListener('touchstart', arguments.callee);
265 this.parentNode.removeChild(this);
266 ctl.backgroundMap.removeChild(this);
268 this.lifetime = null;
275 GPopup = enchant.Class.create(enchant.Sprite, {
276 initialize : function(scene, x, y, w, h) {
277 enchant.Sprite.call(this, w, h);
278 this.image = new Surface(w, h);
281 scene.addChild(this);
286 this.image.context.fillStyle = '#000099';
287 this.image.context.fillRect(0, 0, this.getWidth(), this.getHeight());
289 setText : function(text) {
290 this.image.context.fillStyle = 'black';
291 this.image.context.textAlign = 'left';
292 this.image.context.textBaseline = 'top';
293 this.image.context.font = "13px 'Times New Roman'";
295 var textWidth = Math.floor(this.image.context.measureText(text).width);
296 var lineHeight = this.image.context.measureText("あ").width;
297 var _textList = text.split("\n");
298 this.renew(this.scene, this.x, this.y, textWidth, (lineHeight) * _textList.length + 6);
301 drawText : function (){
305 // var lineHeight = this.image.context.measureText("あ").width;
306 this.image.context.fillStyle = '#ffffff';
307 this.image.context.textAlign = 'left';
308 this.image.context.textBaseline = 'alphabetic';
309 this.image.context.font = "12px 'Times New Roman'";
310 this.fillTextLine(this.text ,x, y);
312 getWidth : function(){
313 return this.image.width;
315 getHeight : function(){
316 return this.image.height;
318 fillTextLine : function(text, x, y) {
319 var textList = text.split("\n");
320 var lineHeight = this.image.context.measureText("あ").width + 2;
322 textList.forEach(function(text, i) {
323 self.image.context.fillText(text, x, y + lineHeight * (i+1));
326 renew : function(scene, x, y, w, h){
327 scene.removeChild(this);
328 enchant.Sprite.call(this, w, h);
329 this.image = new Surface(w, h);
332 scene.addChild(this);
337 GWindow = enchant.Class.create(enchant.Sprite, {
338 initialize : function(scene, x, y, w, h) {
339 enchant.Sprite.call(this, w, h);
340 this.image = new Surface(w, h);
343 scene.addChild(this);
346 this.image.context.fillStyle = '#ffff00';
347 this.image.context.fillRect(0, 0, this.getWidth(), this.getHeight());
349 text : function(text, x, y) {
351 this.image.context.fillStyle = 'black';
352 this.image.context.textAlign = 'left';
353 this.image.context.textBaseline = 'middle';
354 this.image.context.font = "12px 'Times New Roman'";
355 var textWidth = Math.floor(this.image.context.measureText(text).width);
357 var lineHeight = this.image.context.measureText("あ").width;
358 this.image.context.fillText(text + ":" + textWidth,x, y + lineHeight);
360 getWidth : function(){
361 return this.image.width;
363 getHeight : function(){
364 return this.image.height;
367 renew : function(scene, x, y, w, h){
368 scene.removeChild(this);
369 enchant.Sprite.call(this, w, h);
370 this.image = new Surface(w, h);
373 scene.addChild(this);
376 App.YUtil = enchant.Class.create(enchant.Sprite,{
377 randomLooks : function(){
378 return rand(_.size(ELooks));
384 //var tweet = new TTweet(128, 64);
385 //tweet.text("ABCDEFG");