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) {
90 with(this.image.context) {
91 // var size = measureText(text);
94 textBaseline = 'middle';
97 // fillText(text,this.width/2,this.height/2);
100 // console.log(this.width);
102 var textList = text.split("\n");
103 var len = textList.length / 2;
104 var height = (this.height/(1 + len));
105 this.fillTextLine(text,this.width/2, height);
110 fillTextLine : function(text, x, y) {
111 var textList = text.split("\n");
112 var lineHeight = this.image.context.measureText("あ").width + 2;
114 textList.forEach(function(text, i) {
115 self.image.context.fillText(text, x, y + lineHeight * i);
126 var Box = enchant.Class.create(enchant.Sprite, {
127 initialize : function(ctl, node, x, y, w, h) {
128 enchant.Sprite.call(this, w, h + TTweet.TAIL);
138 ctl.game.rootScene.addEventListener('touchstart', this.touchstart(this));
139 ctl.backgroundMap.addChild(this);
143 this.image = new Surface(w, h + TTweet.TAIL);
146 var c = TTweet.CURVE;
154 lt : {x: 0+s, y: t+s},
155 rt : {x: w-s, y: t+s},
156 rd : {x: w-s, y:h+t-s},
157 ld : {x: 0+s, y:h+t-s}
159 this.image.context.font = "12px 'Times New Roman'";
161 this.addEventListener('enterframe', function(){
162 if((this.age % BASE_FPS) == 0){
166 if(this.lifetime <= 0){
169 this.removeEventListener('enterframe', arguments.callee);
174 reDraw : function() {
175 var c = TTweet.CURVE;
176 var o = this.outCurve;
177 with(this.image.context) {
180 strokeStyle = 'black';
182 moveTo(o.lt.x, o.lt.y+c);
183 quadraticCurveTo(o.lt.x, o.lt.y, o.lt.x+c, o.lt.y);
184 lineTo(o.rt.x-c, o.rt.y);
185 quadraticCurveTo(o.rt.x, o.rt.y, o.rt.x, o.rt.y+c);
186 lineTo(o.rd.x, o.rd.y-c);
187 quadraticCurveTo(o.rd.x, o.rd.y, o.rd.x-c, o.rd.y);
188 lineTo(o.ld.x+c, o.ld.y);
189 quadraticCurveTo(o.ld.x, o.ld.y, o.ld.x, o.ld.y-c);
197 var c = TTweet.CURVE;
198 var o = this.outCurve;
199 var i = this.inCurve;
200 with(this.image.context) {
204 moveTo(i.lt.x, o.lt.y+c);
205 quadraticCurveTo(i.lt.x, i.lt.y, o.lt.x+c, i.lt.y);
206 lineTo(o.rt.x-c, i.rt.y);
207 quadraticCurveTo(i.rt.x, i.rt.y, i.rt.x, o.rt.y+c);
208 lineTo(i.rd.x, o.rd.y-c);
209 quadraticCurveTo(i.rd.x, i.rd.y, o.rd.x-c, i.rd.y);
210 lineTo(o.ld.x+c, i.ld.y);
211 quadraticCurveTo(i.ld.x, i.ld.y, i.ld.x, o.ld.y-c);
216 drawBox : function() {
219 text = this.node.getStatusForDisplay();
221 with(this.image.context) {
223 textAlign = 'center';
224 textBaseline = 'middle';
225 var textList = text.split("\n");
226 var len = textList.length / 2;
227 var height = (this.height/(1 + len));
228 this.fillTextLine(text,this.width/2, height);
231 fillTextLine : function(text, x, y) {
232 var textList = text.split("\n");
233 var lineHeight = this.image.context.measureText("あ").width + 2;
235 textList.forEach(function(text, i) {
236 self.image.context.fillText(text, x, y + lineHeight * i);
245 getWidth: function(){
248 getHeight: function(){
251 touchstart:function(self){
253 if(typeof e === "undefined")return;
254 // this.removeEventListener('touchstart', arguments.callee);
256 // if(self.x <= e.x && self.x + self.width >= e.x
257 // && self.y <= e.y && self.y + self.height >= e.y
259 if(ctl.isCollision(e, self)){
260 this.removeEventListener('touchstart', arguments.callee);
267 this.parentNode.removeChild(this);
268 ctl.backgroundMap.removeChild(this);
270 this.lifetime = null;
277 GPopup = enchant.Class.create(enchant.Sprite, {
278 initialize : function(scene, x, y, w, h) {
279 enchant.Sprite.call(this, w, h);
280 this.image = new Surface(w, h);
283 scene.addChild(this);
288 this.image.context.fillStyle = '#000099';
289 this.image.context.fillRect(0, 0, this.getWidth(), this.getHeight());
291 setText : function(text) {
292 this.image.context.fillStyle = 'black';
293 this.image.context.textAlign = 'left';
294 this.image.context.textBaseline = 'top';
295 this.image.context.font = "13px 'Times New Roman'";
297 var textWidth = Math.floor(this.image.context.measureText(text).width);
298 var lineHeight = this.image.context.measureText("あ").width;
299 var _textList = text.split("\n");
300 this.renew(this.scene, this.x, this.y, textWidth, (lineHeight) * _textList.length + 6);
303 drawText : function (){
307 // var lineHeight = this.image.context.measureText("あ").width;
308 this.image.context.fillStyle = '#ffffff';
309 this.image.context.textAlign = 'left';
310 this.image.context.textBaseline = 'alphabetic';
311 this.image.context.font = "12px 'Times New Roman'";
312 this.fillTextLine(this.text ,x, y);
314 getWidth : function(){
315 return this.image.width;
317 getHeight : function(){
318 return this.image.height;
320 fillTextLine : function(text, x, y) {
321 var textList = text.split("\n");
322 var lineHeight = this.image.context.measureText("あ").width + 2;
324 textList.forEach(function(text, i) {
325 self.image.context.fillText(text, x, y + lineHeight * (i+1));
328 renew : function(scene, x, y, w, h){
329 scene.removeChild(this);
330 enchant.Sprite.call(this, w, h);
331 this.image = new Surface(w, h);
334 scene.addChild(this);
339 GWindow = enchant.Class.create(enchant.Sprite, {
340 initialize : function(scene, x, y, w, h) {
341 enchant.Sprite.call(this, w, h);
342 this.image = new Surface(w, h);
345 scene.addChild(this);
348 this.image.context.fillStyle = '#ffff00';
349 this.image.context.fillRect(0, 0, this.getWidth(), this.getHeight());
351 text : function(text, x, y) {
353 this.image.context.fillStyle = 'black';
354 this.image.context.textAlign = 'left';
355 this.image.context.textBaseline = 'middle';
356 this.image.context.font = "12px 'Times New Roman'";
357 var textWidth = Math.floor(this.image.context.measureText(text).width);
359 var lineHeight = this.image.context.measureText("あ").width;
360 this.image.context.fillText(text + ":" + textWidth,x, y + lineHeight);
362 getWidth : function(){
363 return this.image.width;
365 getHeight : function(){
366 return this.image.height;
369 renew : function(scene, x, y, w, h){
370 scene.removeChild(this);
371 enchant.Sprite.call(this, w, h);
372 this.image = new Surface(w, h);
375 scene.addChild(this);
378 App.YUtil = enchant.Class.create(enchant.Sprite,{
379 randomLooks : function(){
380 return rand(_.size(ELooks));
386 //var tweet = new TTweet(128, 64);
387 //tweet.text("ABCDEFG");