Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/src/js/jgame.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 34 by tsugehara, Wed Feb 27 02:32:54 2013 UTC revision 35 by tsugehara, Thu Feb 28 06:28:53 2013 UTC
# Line 682  var Shape = (function (_super) { Line 682  var Shape = (function (_super) {
682          this.type = type ? type : ShapeType.rect;          this.type = type ? type : ShapeType.rect;
683      }      }
684      Shape.PI_200_PER = Math.PI * 2;      Shape.PI_200_PER = Math.PI * 2;
685        Shape.prototype.setClip = function (value) {
686            this.clip = value;
687            if(this.clip) {
688                this.disableTransform = true;
689            } else {
690                delete this.disableTransform;
691            }
692        };
693      Shape.prototype.setStyle = function (style) {      Shape.prototype.setStyle = function (style) {
694          this.style = style;          this.style = style;
695          this.setColor(this.getColor());          this.setColor(this.getColor());
# Line 714  var Shape = (function (_super) { Line 722  var Shape = (function (_super) {
722          if(this.syncObj) {          if(this.syncObj) {
723              this.syncFunc.call(this.syncObj, this);              this.syncFunc.call(this.syncObj, this);
724          }          }
725            if(this.clip) {
726                context.save();
727                context.translate(area.x + this.x, area.y + this.y);
728                if(this.options) {
729                    this.scene.game.renderer.useDrawOption(this, context);
730                }
731            }
732          context.beginPath();          context.beginPath();
733          switch(this.type) {          switch(this.type) {
734              case ShapeType.rect:              case ShapeType.rect:
# Line 724  var Shape = (function (_super) { Line 739  var Shape = (function (_super) {
739                  context.arc(w2, w2, w2, 0, Shape.PI_200_PER, false);                  context.arc(w2, w2, w2, 0, Shape.PI_200_PER, false);
740                  break;                  break;
741          }          }
742          if(this.style == ShapeStyle.fill) {          if(this.clip) {
743                context.restore();
744                context.clip();
745            } else if(this.style == ShapeStyle.fill) {
746              context.fill();              context.fill();
747          } else {          } else {
748              context.stroke();              context.stroke();
# Line 1790  var Renderer = (function () { Line 1808  var Renderer = (function () {
1808              if(entity.options) {              if(entity.options) {
1809                  this.useDrawOption(entity, c);                  this.useDrawOption(entity, c);
1810              }              }
1811              entity.draw(area, c);              if(entity.filter) {
1812                    this.filterDraw(area, entity, c);
1813                } else {
1814                    entity.draw(area, c);
1815                }
1816              if(entity.entities) {              if(entity.entities) {
1817                  for(var i = 0; i < entity.entities.length; i++) {                  for(var i = 0; i < entity.entities.length; i++) {
1818                      this.renderEntity(new Area(0, 0, entity.width, entity.height), entity.entities[i], c);                      this.renderEntity(new Area(0, 0, entity.width, entity.height), entity.entities[i], c);
# Line 1799  var Renderer = (function () { Line 1821  var Renderer = (function () {
1821              c.restore();              c.restore();
1822          }          }
1823      };      };
1824        Renderer.prototype.renderPure = function (area, entity, c) {
1825            entity.draw(area, c);
1826        };
1827        Renderer.prototype.filterDraw = function (area, entity, c) {
1828            var buffer = new BufferedRenderer(entity);
1829            var bufferArea = new Area(0, 0, entity.width, entity.height);
1830            buffer.filter = entity.filter;
1831            buffer.renderPure(bufferArea, entity, buffer.c);
1832            buffer.applyFilter(buffer.c, bufferArea);
1833            buffer.draw(area, c);
1834        };
1835      Renderer.prototype.useDrawOption = function (entity, c) {      Renderer.prototype.useDrawOption = function (entity, c) {
1836          for(var p in entity.options) {          for(var p in entity.options) {
1837              if(this.drawOptionFunctions[p]) {              if(this.drawOptionFunctions[p]) {
# Line 2025  var BufferedRenderer = (function (_super Line 2058  var BufferedRenderer = (function (_super
2058          this.buffer = window.createCanvas(this.size.width, this.size.height);          this.buffer = window.createCanvas(this.size.width, this.size.height);
2059          this.c = this.buffer.getContext("2d");          this.c = this.buffer.getContext("2d");
2060      };      };
2061        BufferedRenderer.prototype.draw = function (area, context) {
2062            context.drawImage(this.buffer, 0, 0, this.size.width, this.size.height, 0, 0, this.size.width, this.size.height);
2063        };
2064      return BufferedRenderer;      return BufferedRenderer;
2065  })(Renderer);  })(Renderer);
2066  var GameTimer = (function () {  var GameTimer = (function () {
# Line 2286  var Game = (function () { Line 2322  var Game = (function () {
2322      Game.prototype.exit = function () {      Game.prototype.exit = function () {
2323          this._exit = true;          this._exit = true;
2324      };      };
2325      Game.prototype.changeScene = function (scene) {      Game.prototype.changeScene = function (scene, effect, endOldScene) {
2326            var _this = this;
2327            if(effect) {
2328                var currentScene = this.currentScene;
2329                Effect.sceneEffect(this, currentScene, scene, effect, function () {
2330                    _this.endScene();
2331                    _this.changeScene(scene);
2332                }, endOldScene);
2333                return;
2334            }
2335          this.scenes.push(scene);          this.scenes.push(scene);
2336          scene.game = this;          scene.game = this;
2337          this.currentScene.hid.fire();          this.currentScene.hid.fire();
# Line 2294  var Game = (function () { Line 2339  var Game = (function () {
2339          this.renderer.changeScene(this.currentScene);          this.renderer.changeScene(this.currentScene);
2340          this.currentScene.started.fire();          this.currentScene.started.fire();
2341      };      };
2342      Game.prototype.endScene = function () {      Game.prototype.endScene = function (effect) {
2343            var _this = this;
2344          if(this.scenes.length == 1) {          if(this.scenes.length == 1) {
2345              this.exit();              this.exit();
2346              return;              return;
2347          }          }
2348            if(effect) {
2349                Effect.sceneEffect(this, this.currentScene, this.scenes[this.scenes.length - 2], effect, function () {
2350                    _this.endScene();
2351                }, true);
2352                return;
2353            }
2354          this.currentScene.destroy();          this.currentScene.destroy();
2355          this.scenes.pop();          this.scenes.pop();
2356          this.currentScene.ended.fire();          this.currentScene.ended.fire();
# Line 2476  var ImageFilter; Line 2528  var ImageFilter;
2528              this.filters.push(filter);              this.filters.push(filter);
2529              return this;              return this;
2530          };          };
2531            FilterChain.prototype.set = function (filter) {
2532                this.filters = [
2533                    filter
2534                ];
2535                return this;
2536            };
2537          FilterChain.prototype.insert = function (index, filter) {          FilterChain.prototype.insert = function (index, filter) {
2538              for(var i = 1; i < arguments.length; i++) {              for(var i = 1; i < arguments.length; i++) {
2539                  this.filters.splice(index, 0, arguments[i]);                  this.filters.splice(index, 0, arguments[i]);
2540              }              }
2541              return this;              return this;
2542          };          };
2543            FilterChain.prototype.remove = function (filter) {
2544                for(var i = 0; i < this.filters.length; i++) {
2545                    if(this.filters[i] == filter) {
2546                        this.filters.splice(i, 1);
2547                        return;
2548                    }
2549                }
2550            };
2551          FilterChain.prototype.clear = function () {          FilterChain.prototype.clear = function () {
2552              this.filters = [];              this.filters = [];
2553              return this;              return this;
# Line 2493  var ImageFilter; Line 2559  var ImageFilter;
2559              return this.filters.length > 0;              return this.filters.length > 0;
2560          };          };
2561          FilterChain.prototype.createSprite = function (entity) {          FilterChain.prototype.createSprite = function (entity) {
2562              return null;              var buffer = new BufferedRenderer({
2563                    width: entity.width,
2564                    height: entity.height
2565                });
2566                buffer.filter = this;
2567                var x = entity.x;
2568                var y = entity.y;
2569                entity.x = 0;
2570                entity.y = 0;
2571                buffer.renderUnit(entity);
2572                entity.x = x;
2573                entity.y = y;
2574                return buffer.createSprite();
2575            };
2576            FilterChain.prototype.createImage = function (entity) {
2577                var buffer = new BufferedRenderer({
2578                    width: entity.image.width,
2579                    height: entity.image.height
2580                });
2581                var image = new Sprite(entity.image.width, entity.image.height, entity.image);
2582                image.x = 0;
2583                image.y = 0;
2584                buffer.filter = this;
2585                buffer.renderUnit(image);
2586                return buffer.createImage();
2587          };          };
2588          FilterChain.prototype.filter = function (pixels) {          FilterChain.prototype.filter = function (pixels) {
2589              var length = this.filters.length;              var length = this.filters.length;
# Line 2830  var ImageFilter; Line 2920  var ImageFilter;
2920          }          }
2921          MosaicFilter.prototype.filter = function (pixels) {          MosaicFilter.prototype.filter = function (pixels) {
2922              var opacity = this.getOption("opacity", 1);              var opacity = this.getOption("opacity", 1);
2923              var size = this.getOption("size", 5);              var size = Math.round(this.getOption("size", 5));
2924              var width = pixels.width;              var width = pixels.width;
2925              for(var i = 0, data = pixels.data, length = data.length; i < length >> 2; i++) {              for(var i = 0, data = pixels.data, length = data.length; i < length >> 2; i++) {
2926                  var index = i << 2;                  var index = i << 2;
# Line 3006  var ParallelAction = (function (_super) Line 3096  var ParallelAction = (function (_super)
3096              this.actions[i].action_tick.fire(e);              this.actions[i].action_tick.fire(e);
3097          }          }
3098          if(this.actions.length === 0) {          if(this.actions.length === 0) {
3099              evt.timeline.next();              evt.timeline.next(1);
3100          }          }
3101      };      };
3102      ParallelAction.prototype.parallelActionStart = function (e) {      ParallelAction.prototype.parallelActionStart = function (e) {
# Line 3093  var Tween = (function (_super) { Line 3183  var Tween = (function (_super) {
3183      }      }
3184      Tween.prototype.actionStart = function (e) {      Tween.prototype.actionStart = function (e) {
3185          for(var prop in this.props) {          for(var prop in this.props) {
3186                if(prop == "filter") {
3187                    var filter = new this.props[prop].targetClass();
3188                    if(!this.entity.filter) {
3189                        this.entity.filter = new ImageFilter.FilterChain();
3190                    }
3191                    this.entity.filter.add(filter);
3192                    if(this.props[prop].autoDelete) {
3193                        this.removed_from_timeline.handleInsert(0, this, function () {
3194                            this.entity.filter.remove(filter);
3195                            if(this.entity.filter.length == 0) {
3196                                delete this.entity.filter;
3197                            }
3198                        });
3199                    }
3200                    this.target[prop] = {
3201                    };
3202                    this.origin[prop] = {
3203                    };
3204                    this.old[prop] = {
3205                    };
3206                    for(var j in this.props[prop]) {
3207                        if(j == "targetClass" || j == "autoDelete") {
3208                            continue;
3209                        }
3210                        if(this.props[prop][j].start !== undefined) {
3211                            var s = this.props[prop][j].start;
3212                            filter.opt[j] = s;
3213                            this.origin[prop][j] = s;
3214                            this.old[prop][j] = s;
3215                            this.target[prop][j] = this.props[prop][j].end;
3216                        } else {
3217                            filter.opt[j] = this.props[prop][j];
3218                        }
3219                    }
3220                    this.otherTarget = filter;
3221                    continue;
3222                }
3223              var target_val;              var target_val;
3224              if(typeof this.props[prop] === "function") {              if(typeof this.props[prop] === "function") {
3225                  target_val = this.props[prop].call(this.entity);                  target_val = this.props[prop].call(this.entity);
# Line 3117  var Tween = (function (_super) { Line 3244  var Tween = (function (_super) {
3244              if(TWEEN_DRAW_OPTION_SETTERS[prop]) {              if(TWEEN_DRAW_OPTION_SETTERS[prop]) {
3245                  var f = TWEEN_DRAW_OPTION_SETTERS[prop];                  var f = TWEEN_DRAW_OPTION_SETTERS[prop];
3246                  this.old[prop] = f(this.entity, prop, this.old[prop], this.target[prop], this.origin[prop], ratio);                  this.old[prop] = f(this.entity, prop, this.old[prop], this.target[prop], this.origin[prop], ratio);
3247                } else if(prop == "filter") {
3248                    for(var j in this.target[prop]) {
3249                        this.otherTarget.opt[j] = this.old[prop][j] + (this.target[prop][j] - this.origin[prop][j]) * ratio;
3250                        if(Math.abs(this.otherTarget.opt[j]) < 1e-7) {
3251                            this.otherTarget.opt[j] = 0;
3252                        }
3253                        this.old[prop][j] = this.otherTarget.opt[j];
3254                    }
3255              } else {              } else {
3256                  this.entity[prop] = this.old[prop] + (this.target[prop] - this.origin[prop]) * ratio;                  this.entity[prop] = this.old[prop] + (this.target[prop] - this.origin[prop]) * ratio;
3257                  if(Math.abs(this.entity[prop]) < 1e-7) {                  if(Math.abs(this.entity[prop]) < 1e-7) {
# Line 3181  var Timeline = (function () { Line 3316  var Timeline = (function () {
3316              });              });
3317          }          }
3318          if(this.queue.length === 0 && !this.looped) {          if(this.queue.length === 0 && !this.looped) {
3319                action.removed_from_timeline.fire({
3320                    timeline: this
3321                });
3322              this._deactivateTimeline(true);              this._deactivateTimeline(true);
3323              return;              return;
3324          }          }
# Line 3537  var Timeline = (function () { Line 3675  var Timeline = (function () {
3675              easing: easing              easing: easing
3676          });          });
3677      };      };
3678        Timeline.prototype.filter = function (targetClass, props, time, easing) {
3679            var filterVal = {
3680                targetClass: targetClass,
3681                autoDelete: true
3682            };
3683            for(var i in props) {
3684                filterVal[i] = props[i];
3685            }
3686            return this.tween({
3687                filter: filterVal,
3688                time: time,
3689                easing: easing
3690            });
3691        };
3692      Timeline.prototype.removeFromScene = function () {      Timeline.prototype.removeFromScene = function () {
3693          return this.then(function () {          return this.then(function () {
3694              this.remove();              this.remove();
# Line 3866  var Line = (function (_super) { Line 4018  var Line = (function (_super) {
4018              this.setLineWidth(width);              this.setLineWidth(width);
4019          }          }
4020      }      }
4021        Line.prototype.setClip = function (value) {
4022            this.clip = value;
4023            if(this.clip) {
4024                this.disableTransform = true;
4025            } else {
4026                delete this.disableTransform;
4027            }
4028        };
4029      Line.prototype.updateSize = function () {      Line.prototype.updateSize = function () {
4030          var min = {          var min = {
4031              x: this.p[0].x,              x: this.p[0].x,
# Line 4044  var Line = (function (_super) { Line 4204  var Line = (function (_super) {
4204      };      };
4205      Line.prototype.draw = function (area, context) {      Line.prototype.draw = function (area, context) {
4206          context.beginPath();          context.beginPath();
4207            if(this.clip) {
4208                context.save();
4209                context.translate(area.x + this.x, area.y + this.y);
4210                if(this.options) {
4211                    this.scene.game.renderer.useDrawOption(this, context);
4212                }
4213            }
4214          context.moveTo(0, 0);          context.moveTo(0, 0);
4215          for(var i = 1; i < this.p.length; i++) {          for(var i = 1; i < this.p.length; i++) {
4216              var p = this.p[i];              var p = this.p[i];
# Line 4063  var Line = (function (_super) { Line 4230  var Line = (function (_super) {
4230          if(this.closePath) {          if(this.closePath) {
4231              context.closePath();              context.closePath();
4232          }          }
4233          if(this.fill) {          if(this.clip) {
4234                context.restore();
4235                context.clip();
4236            } else if(this.fill) {
4237              context.fill();              context.fill();
4238              if(this.stroke) {              if(this.stroke) {
4239                  context.stroke();                  context.stroke();
# Line 4074  var Line = (function (_super) { Line 4244  var Line = (function (_super) {
4244      };      };
4245      return Line;      return Line;
4246  })(E);  })(E);
4247    var EffectType;
4248    (function (EffectType) {
4249        EffectType._map = [];
4250        EffectType._map[0] = "None";
4251        EffectType.None = 0;
4252        EffectType._map[1] = "Fade";
4253        EffectType.Fade = 1;
4254        EffectType._map[2] = "Mosaic";
4255        EffectType.Mosaic = 2;
4256        EffectType._map[3] = "Blur";
4257        EffectType.Blur = 3;
4258        EffectType._map[4] = "SlideUp";
4259        EffectType.SlideUp = 4;
4260        EffectType._map[5] = "SlideDown";
4261        EffectType.SlideDown = 5;
4262        EffectType._map[6] = "SlideLeft";
4263        EffectType.SlideLeft = 6;
4264        EffectType._map[7] = "SlideRight";
4265        EffectType.SlideRight = 7;
4266        EffectType._map[8] = "WipeUp";
4267        EffectType.WipeUp = 8;
4268        EffectType._map[9] = "WipeDown";
4269        EffectType.WipeDown = 9;
4270        EffectType._map[10] = "WipeLeft";
4271        EffectType.WipeLeft = 10;
4272        EffectType._map[11] = "WipeRight";
4273        EffectType.WipeRight = 11;
4274        EffectType._map[12] = "WipeFadeUp";
4275        EffectType.WipeFadeUp = 12;
4276        EffectType._map[13] = "WipeFadeDown";
4277        EffectType.WipeFadeDown = 13;
4278        EffectType._map[14] = "WipeFadeLeft";
4279        EffectType.WipeFadeLeft = 14;
4280        EffectType._map[15] = "WipeFadeRight";
4281        EffectType.WipeFadeRight = 15;
4282        EffectType._map[16] = "BoxOut";
4283        EffectType.BoxOut = 16;
4284        EffectType._map[17] = "BoxOut45";
4285        EffectType.BoxOut45 = 17;
4286        EffectType._map[18] = "BoxIn";
4287        EffectType.BoxIn = 18;
4288        EffectType._map[19] = "BoxIn45";
4289        EffectType.BoxIn45 = 19;
4290        EffectType._map[20] = "ArcOut";
4291        EffectType.ArcOut = 20;
4292        EffectType._map[21] = "ArcIn";
4293        EffectType.ArcIn = 21;
4294        EffectType._map[22] = "BoxOutBlack";
4295        EffectType.BoxOutBlack = 22;
4296        EffectType._map[23] = "BoxOut45Black";
4297        EffectType.BoxOut45Black = 23;
4298        EffectType._map[24] = "BoxInBlack";
4299        EffectType.BoxInBlack = 24;
4300        EffectType._map[25] = "BoxIn45Black";
4301        EffectType.BoxIn45Black = 25;
4302        EffectType._map[26] = "ArcOutBlack";
4303        EffectType.ArcOutBlack = 26;
4304        EffectType._map[27] = "ArcInBlack";
4305        EffectType.ArcInBlack = 27;
4306        EffectType._map[28] = "BoxOutWhite";
4307        EffectType.BoxOutWhite = 28;
4308        EffectType._map[29] = "BoxOut45White";
4309        EffectType.BoxOut45White = 29;
4310        EffectType._map[30] = "BoxInWhite";
4311        EffectType.BoxInWhite = 30;
4312        EffectType._map[31] = "BoxIn45White";
4313        EffectType.BoxIn45White = 31;
4314        EffectType._map[32] = "ArcOutWhite";
4315        EffectType.ArcOutWhite = 32;
4316        EffectType._map[33] = "ArcInWhite";
4317        EffectType.ArcInWhite = 33;
4318    })(EffectType || (EffectType = {}));
4319    var Effect = (function () {
4320        function Effect(method) {
4321            this.method = method;
4322            this.arguments = [];
4323            for(var i = 1; i < arguments.length; i++) {
4324                this.arguments.push(arguments[i]);
4325            }
4326        }
4327        Effect.time = 1000;
4328        Effect.sceneEffect = function sceneEffect(game, scene1, scene2, type, callback, endOldScene) {
4329            var effect = new EffectScene(game, scene1, scene2);
4330            if(endOldScene) {
4331                game.endScene();
4332                if(game._exit) {
4333                    return;
4334                }
4335            }
4336            game.changeScene(effect);
4337            effect.effected.handle(game, callback);
4338            if(typeof type == "number") {
4339                switch(type) {
4340                    case EffectType.Fade:
4341                        effect.fade(Effect.color);
4342                        break;
4343                    case EffectType.Mosaic:
4344                        effect.mosaic();
4345                        break;
4346                    case EffectType.Blur:
4347                        effect.blur();
4348                        break;
4349                    case EffectType.SlideUp:
4350                        effect.slide(Angle.up);
4351                        break;
4352                    case EffectType.SlideDown:
4353                        effect.slide(Angle.down);
4354                        break;
4355                    case EffectType.SlideLeft:
4356                        effect.slide(Angle.left);
4357                        break;
4358                    case EffectType.SlideRight:
4359                        effect.slide(Angle.right);
4360                        break;
4361                    case EffectType.WipeUp:
4362                        effect.wipe(Angle.up);
4363                        break;
4364                    case EffectType.WipeDown:
4365                        effect.wipe(Angle.down);
4366                        break;
4367                    case EffectType.WipeLeft:
4368                        effect.wipe(Angle.left);
4369                        break;
4370                    case EffectType.WipeRight:
4371                        effect.wipe(Angle.right);
4372                        break;
4373                    case EffectType.WipeFadeUp:
4374                        effect.wipeFade(Angle.up);
4375                        break;
4376                    case EffectType.WipeFadeDown:
4377                        effect.wipeFade(Angle.down);
4378                        break;
4379                    case EffectType.WipeFadeLeft:
4380                        effect.wipeFade(Angle.left);
4381                        break;
4382                    case EffectType.WipeFadeRight:
4383                        effect.wipeFade(Angle.right);
4384                        break;
4385                    case EffectType.BoxOut:
4386                        effect.boxOut(0, Effect.color);
4387                        break;
4388                    case EffectType.BoxOut45:
4389                        effect.boxOut(45, Effect.color);
4390                        break;
4391                    case EffectType.BoxIn:
4392                        effect.boxIn(0, Effect.color);
4393                        break;
4394                    case EffectType.BoxIn45:
4395                        effect.boxIn(45, Effect.color);
4396                        break;
4397                    case EffectType.ArcIn:
4398                        effect.arcIn(Effect.color);
4399                        break;
4400                    case EffectType.ArcOut:
4401                        effect.arcOut(Effect.color);
4402                        break;
4403                }
4404            } else {
4405                this.callEffect(effect);
4406            }
4407        };
4408        Effect.prototype.callEffect = function (scene) {
4409            scene[this.method].apply(scene, this.arguments);
4410        };
4411        return Effect;
4412    })();
4413    var EffectScene = (function (_super) {
4414        __extends(EffectScene, _super);
4415        function EffectScene(game, scene1, scene2) {
4416            _super.call(this, game);
4417            var sp1 = this.captureScene(scene1);
4418            var sp2 = this.captureScene(scene2);
4419            sp2.setDrawOption("globalAlpha", 0);
4420            sp1.x = sp1.y = sp2.x = sp2.y = 0;
4421            this.append(sp1);
4422            this.append(sp2);
4423            this.sp1 = sp1;
4424            this.sp2 = sp2;
4425            this.effected = new Trigger();
4426        }
4427        EffectScene.prototype.captureScene = function (scene) {
4428            var buffer = new BufferedRenderer(this.game);
4429            buffer.renderScene(scene);
4430            return buffer.createSprite();
4431        };
4432        EffectScene.prototype.fade = function (color) {
4433            var _this = this;
4434            if(color) {
4435                this._fadeColor(color);
4436                return;
4437            }
4438            this.sp1.tl().fadeOut(Effect.time).removeFromScene();
4439            this.sp2.tl().fadeIn(Effect.time).then(function () {
4440                _this.effected.fire();
4441            });
4442        };
4443        EffectScene.prototype._fadeColor = function (color) {
4444            var _this = this;
4445            var shape = new Shape(this.sp1.width, this.sp1.height, ShapeStyle.fill, color);
4446            shape.setDrawOption("globalAlpha", 0);
4447            this.root.append(shape);
4448            var t = Effect.time / 2;
4449            this.sp1.tl().fadeOut(t);
4450            shape.tl().fadeIn(t).fadeOut(t).removeFromScene();
4451            this.sp2.tl().delay(t).fadeIn(t).then(function () {
4452                _this.effected.fire();
4453            });
4454        };
4455        EffectScene.prototype.mosaic = function () {
4456            var _this = this;
4457            var t = Effect.time / 2;
4458            this.sp1.tl().filter(ImageFilter.MosaicFilter, {
4459                size: {
4460                    start: 1,
4461                    end: 64
4462                }
4463            }, t).removeFromScene();
4464            this.sp2.tl().delay(t).show().filter(ImageFilter.MosaicFilter, {
4465                size: {
4466                    start: 64,
4467                    end: 1
4468                }
4469            }, t).then(function () {
4470                _this.effected.fire();
4471            });
4472        };
4473        EffectScene.prototype.blur = function () {
4474            var _this = this;
4475            var t = Effect.time / 2;
4476            this.sp1.tl().filter(ImageFilter.BlurFilter, {
4477                amount: {
4478                    start: 1,
4479                    end: 20
4480                }
4481            }, t, Easing.CUBIC_EASEIN).removeFromScene();
4482            this.sp2.tl().delay(t).show().filter(ImageFilter.BlurFilter, {
4483                amount: {
4484                    start: 20,
4485                    end: 1
4486                }
4487            }, t, Easing.CUBIC_EASEOUT).then(function () {
4488                _this.effected.fire();
4489            });
4490        };
4491        EffectScene.prototype.slide = function (angle) {
4492            var _this = this;
4493            var t = Effect.time;
4494            switch(angle) {
4495                case Angle.up:
4496                    this.sp1.tl().moveTo(0, -this.game.height, t).removeFromScene();
4497                    this.sp2.moveTo(0, this.game.height);
4498                    this.sp2.tl().show().moveTo(0, 0, t);
4499                    break;
4500                case Angle.down:
4501                    this.sp1.tl().moveTo(0, this.game.height, t).removeFromScene();
4502                    this.sp2.moveTo(0, -this.game.height);
4503                    this.sp2.tl().show().moveTo(0, 0, t);
4504                    break;
4505                case Angle.left:
4506                    this.sp1.tl().moveTo(-this.game.width, 0, t).removeFromScene();
4507                    this.sp2.moveTo(this.game.width, 0);
4508                    this.sp2.tl().show().moveTo(0, 0, t);
4509                    break;
4510                case Angle.right:
4511                    this.sp1.tl().moveTo(this.game.width, 0, t).removeFromScene();
4512                    this.sp2.moveTo(-this.game.width, 0);
4513                    this.sp2.tl().show().moveTo(0, 0, t);
4514                    break;
4515            }
4516            this.sp2.tl().then(function () {
4517                _this.effected.fire();
4518            });
4519        };
4520        EffectScene.prototype.wipe = function (angle) {
4521            var _this = this;
4522            var t = Effect.time;
4523            this.sp2.tl().show();
4524            var sp = new Shape(this.game.width, 1, ShapeStyle.fill);
4525            sp.moveTo(0, 0);
4526            sp.setClip(true);
4527            this.root.insert(sp, 1);
4528            switch(angle) {
4529                case Angle.up:
4530                    sp.width = this.game.width;
4531                    sp.height = 1;
4532                    sp.y = this.game.height;
4533                    sp.tl().resizeTo(this.game.width, this.game.height, t).and().moveTo(0, 0, t);
4534                    break;
4535                case Angle.down:
4536                    sp.width = this.game.width;
4537                    sp.height = 1;
4538                    sp.tl().resizeTo(this.game.width, this.game.height, t);
4539                    break;
4540                case Angle.left:
4541                    sp.width = 1;
4542                    sp.height = this.game.height;
4543                    sp.x = this.game.width;
4544                    sp.tl().resizeTo(this.game.width, this.game.height, t).and().moveTo(0, 0, t);
4545                    break;
4546                case Angle.right:
4547                    sp.width = 1;
4548                    sp.height = this.game.height;
4549                    sp.tl().resizeTo(this.game.width, this.game.height, t);
4550                    break;
4551            }
4552            sp.tl().then(function () {
4553                _this.effected.fire();
4554            });
4555        };
4556        EffectScene.prototype.wipeFade = function (angle) {
4557            this.wipe(angle);
4558            this.sp1.tl().fadeOut(Effect.time);
4559        };
4560        EffectScene.prototype.boxOut = function (rotate, color) {
4561            var _this = this;
4562            var t = Effect.time;
4563            this.sp2.tl().fadeIn(t);
4564            var sp = new Shape(1, 1, ShapeStyle.fill);
4565            sp.moveTo(this.game.width / 2, this.game.height / 2);
4566            sp.setClip(true);
4567            if(rotate) {
4568                sp.setDrawOption("rotate", rotate);
4569            }
4570            this.root.insert(sp, 1);
4571            if(color) {
4572                var bg = new Shape(this.game.width, this.game.height, ShapeStyle.fill, color);
4573                this.root.insert(bg, 1);
4574                bg.setDrawOption("globalAlpha", 0);
4575                bg.tl().fadeIn(t * 0.6);
4576            }
4577            if(rotate) {
4578                sp.tl().resizeTo(this.game.width * 2, this.game.height * 2, t).and().moveTo(-this.game.width / 2, -this.game.height / 2, t);
4579            } else {
4580                sp.tl().resizeTo(this.game.width, this.game.height, t).and().moveTo(0, 0, t);
4581            }
4582            sp.tl().then(function () {
4583                _this.effected.fire();
4584            });
4585        };
4586        EffectScene.prototype.boxIn = function (rotate, color) {
4587            var _this = this;
4588            this.swapScene();
4589            var t = Effect.time;
4590            this.sp2.tl().fadeIn(t);
4591            var sp = new Shape(1, 1, ShapeStyle.fill);
4592            if(rotate) {
4593                sp.moveTo(-this.game.width / 2, -this.game.height / 2);
4594                sp.width = this.game.width * 2;
4595                sp.height = this.game.height * 2;
4596            } else {
4597                sp.moveTo(0, 0);
4598                sp.width = this.game.width;
4599                sp.height = this.game.height;
4600            }
4601            sp.setClip(true);
4602            if(rotate) {
4603                sp.setDrawOption("rotate", rotate);
4604            }
4605            this.root.insert(sp, 1);
4606            if(color) {
4607                var bg = new Shape(sp.width, sp.height, ShapeStyle.fill, color);
4608                bg.moveTo(sp.x, sp.y);
4609                this.root.append(bg);
4610                bg.setDrawOption("globalAlpha", 0);
4611                bg.tl().fadeIn(t * 0.8).and().resizeTo(1, 1, t).and().moveTo(this.game.width / 2, this.game.height / 2, t);
4612                if(rotate) {
4613                    bg.setDrawOption("rotate", rotate);
4614                }
4615            } else {
4616                this.sp1.tl().fadeOut(t);
4617            }
4618            sp.tl().resizeTo(1, 1, t).and().moveTo(this.game.width / 2, this.game.height / 2, t);
4619            sp.tl().then(function () {
4620                _this.effected.fire();
4621            });
4622        };
4623        EffectScene.prototype.arcOut = function (color) {
4624            var _this = this;
4625            var t = Effect.time;
4626            this.sp2.tl().fadeIn(t);
4627            var sp = new Shape(1, 1, ShapeStyle.fill, "black", ShapeType.arc);
4628            sp.moveTo(this.game.width / 2, this.game.height / 2);
4629            sp.setClip(true);
4630            this.root.insert(sp, 1);
4631            if(color) {
4632                var bg = new Shape(this.game.width, this.game.height, ShapeStyle.fill, color);
4633                this.root.insert(bg, 1);
4634                bg.setDrawOption("globalAlpha", 0);
4635                bg.tl().fadeIn(t * 0.6);
4636            }
4637            sp.tl().resizeTo(this.game.width * 2, this.game.height * 2, t).and().moveTo(-this.game.width / 2, -this.game.height / 2, t);
4638            sp.tl().then(function () {
4639                _this.effected.fire();
4640            });
4641        };
4642        EffectScene.prototype.arcIn = function (color) {
4643            var _this = this;
4644            this.swapScene();
4645            var t = Effect.time;
4646            this.sp2.tl().fadeIn(t);
4647            var sp = new Shape(1, 1, ShapeStyle.fill, "black", ShapeType.arc);
4648            sp.moveTo(-this.game.width / 2, -this.game.height / 2);
4649            sp.width = this.game.width * 2;
4650            sp.height = this.game.height * 2;
4651            sp.setClip(true);
4652            this.root.insert(sp, 1);
4653            if(color) {
4654                var bg = new Shape(sp.width, sp.height, ShapeStyle.fill, color);
4655                bg.moveTo(sp.x, sp.y);
4656                this.root.append(bg);
4657                bg.setDrawOption("globalAlpha", 0);
4658                bg.tl().fadeIn(t * 0.9).and().resizeTo(1, 1, t).and().moveTo(this.game.width / 2, this.game.height / 2, t);
4659            } else {
4660                this.sp1.tl().fadeOut(t);
4661            }
4662            sp.tl().resizeTo(1, 1, t).and().moveTo(this.game.width / 2, this.game.height / 2, t);
4663            sp.tl().then(function () {
4664                _this.effected.fire();
4665            });
4666        };
4667        EffectScene.prototype.getFilter = function (target) {
4668            if(!target.filter) {
4669                target.filter = new ImageFilter.FilterChain();
4670            }
4671            return target.filter;
4672        };
4673        EffectScene.prototype.swapScene = function () {
4674            var tmp = this.root.entities[0];
4675            this.root.entities[0] = this.root.entities[1];
4676            this.root.entities[1] = tmp;
4677        };
4678        return EffectScene;
4679    })(Scene);

Legend:
Removed from v.34  
changed lines
  Added in v.35

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26