1 TTweet = enchant.Class.create(enchant.Sprite, {
2 initialize : function(w, h) {
4 enchant.Sprite.call(this, w, h + TTweet.TAIL);
5 this.image = new Surface(w, h + TTweet.TAIL);
16 lt : {x: 0+s, y: t+s},
17 rt : {x: w-s, y: t+s},
18 rd : {x: w-s, y:h+t-s},
19 ld : {x: 0+s, y:h+t-s}
21 this.image.context.font = "12px 'Times New Roman'";
22 this.addEventListener('enterframe', function(){
23 if((this.age % 15) == 0){
26 if(this.lifetime <= 0){
34 var o = this.outCurve;
35 with(this.image.context) {
37 strokeStyle = 'black';
39 moveTo(o.lt.x, o.lt.y+c);
40 quadraticCurveTo(o.lt.x, o.lt.y, o.lt.x+c, o.lt.y);
41 lineTo(o.rt.x-c, o.rt.y);
42 quadraticCurveTo(o.rt.x, o.rt.y, o.rt.x, o.rt.y+c);
43 lineTo(o.rd.x, o.rd.y-c);
44 quadraticCurveTo(o.rd.x, o.rd.y, o.rd.x-c, o.rd.y);
45 lineTo(o.ld.x+c, o.ld.y);
46 quadraticCurveTo(o.ld.x, o.ld.y, o.ld.x, o.ld.y-c);
49 // lineTo(this.width/2-4,_height + TTweet.TAIL);
50 // lineTo(this.width/2,_height + 0);
51 // lineTo(this.width/2+4,_height + TTweet.TAIL);
60 var o = this.outCurve;
62 with(this.image.context) {
66 moveTo(i.lt.x, o.lt.y+c);
67 quadraticCurveTo(i.lt.x, i.lt.y, o.lt.x+c, i.lt.y);
68 lineTo(o.rt.x-c, i.rt.y);
69 quadraticCurveTo(i.rt.x, i.rt.y, i.rt.x, o.rt.y+c);
70 lineTo(i.rd.x, o.rd.y-c);
71 quadraticCurveTo(i.rd.x, i.rd.y, o.rd.x-c, i.rd.y);
72 lineTo(o.ld.x+c, i.ld.y);
73 quadraticCurveTo(i.ld.x, i.ld.y, i.ld.x, o.ld.y-c);
78 text : function(text, x, y) {
83 with(this.image.context) {
84 // var size = measureText(text);
87 textBaseline = 'middle';
90 // fillText(text,this.width/2,this.height/2);
93 // console.log(this.width);
95 this.fillTextLine(text,this.width/2,this.height/2);
100 fillTextLine : function(text, x, y) {
101 var textList = text.split("\n");
102 var lineHeight = this.image.context.measureText("あ").width + 2;
104 textList.forEach(function(text, i) {
105 self.image.context.fillText(text, x, y + lineHeight * i);
116 //var tweet = new TTweet(128, 64);
117 //tweet.text("ABCDEFG");