| 829 |
return null; |
return null; |
| 830 |
} |
} |
| 831 |
}; |
}; |
| 832 |
SimpleSound.play = function play(sound, loop, when) { |
SimpleSound.play = function play(sound, loop, when, gain) { |
| 833 |
var context = SimpleSound.getAudioContext(); |
var context = SimpleSound.getAudioContext(); |
| 834 |
var bufferSource = context.createBufferSource(); |
var bufferSource = context.createBufferSource(); |
| 835 |
if(loop) { |
if(loop) { |
| 836 |
bufferSource.loop = true; |
bufferSource.loop = true; |
| 837 |
} |
} |
| 838 |
bufferSource.buffer = sound; |
bufferSource.buffer = sound; |
| 839 |
bufferSource.connect(context.destination); |
if(gain) { |
| 840 |
|
bufferSource.connect(gain); |
| 841 |
|
} else { |
| 842 |
|
if(!SimpleSound.soundGain) { |
| 843 |
|
var soundGain = context.createGain(); |
| 844 |
|
soundGain.connect(context.destination); |
| 845 |
|
SimpleSound.soundGain = soundGain; |
| 846 |
|
} |
| 847 |
|
bufferSource.connect(SimpleSound.soundGain); |
| 848 |
|
} |
| 849 |
bufferSource.start(when === undefined ? 0 : when); |
bufferSource.start(when === undefined ? 0 : when); |
| 850 |
return bufferSource; |
return bufferSource; |
| 851 |
}; |
}; |
| 856 |
if(SimpleSound.bgmSource) { |
if(SimpleSound.bgmSource) { |
| 857 |
SimpleSound.stopBgm(); |
SimpleSound.stopBgm(); |
| 858 |
} |
} |
| 859 |
SimpleSound.bgmSource = SimpleSound.play(sound, loop, when); |
if(!SimpleSound.bgmGain) { |
| 860 |
|
var context = SimpleSound.getAudioContext(); |
| 861 |
|
var bgmGain = context.createGain(); |
| 862 |
|
bgmGain.connect(context.destination); |
| 863 |
|
SimpleSound.bgmGain = bgmGain; |
| 864 |
|
} |
| 865 |
|
SimpleSound.bgmSource = SimpleSound.play(sound, loop, when, SimpleSound.bgmGain); |
| 866 |
return SimpleSound.bgmSource; |
return SimpleSound.bgmSource; |
| 867 |
}; |
}; |
| 868 |
SimpleSound.stop = function stop(source, when) { |
SimpleSound.stop = function stop(source, when) { |
| 1630 |
})(E); |
})(E); |
| 1631 |
var LoadingScene = (function (_super) { |
var LoadingScene = (function (_super) { |
| 1632 |
__extends(LoadingScene, _super); |
__extends(LoadingScene, _super); |
| 1633 |
function LoadingScene(game, resource) { |
function LoadingScene(game, resource, noShape) { |
| 1634 |
_super.call(this, game); |
_super.call(this, game); |
| 1635 |
this.resource = resource; |
this.resource = resource; |
| 1636 |
this.resource.loaded.handle(this, this.complete); |
this.resource.loaded.handle(this, this.complete); |
| 1637 |
this.requestCount = this.resource.requests.length; |
this.requestCount = this.resource.requests.length; |
| 1638 |
this.shape = new Shape(game.width, 32); |
this.jgameRequestCount = this.requestCount; |
| 1639 |
this.shape.moveTo(0, game.height / 2 - 16); |
this.finished = new Trigger(); |
| 1640 |
this.shapeP = new Shape(1, 32, ShapeStyle.fill); |
this.otherResources = { |
| 1641 |
this.shapeP.moveTo(0, game.height / 2 - 16); |
}; |
| 1642 |
this.append(this.shape); |
this.otherResourceCount = 0; |
| 1643 |
this.append(this.shapeP); |
this.otherResourceCompleted = 0; |
| 1644 |
} |
this.lastCnt = 0; |
| 1645 |
|
if(!noShape) { |
| 1646 |
|
this.shape = new Shape(game.width, 32); |
| 1647 |
|
this.shape.moveTo(0, game.height / 2 - 16); |
| 1648 |
|
this.shapeP = new Shape(1, 32, ShapeStyle.fill); |
| 1649 |
|
this.shapeP.moveTo(0, game.height / 2 - 16); |
| 1650 |
|
this.append(this.shape); |
| 1651 |
|
this.append(this.shapeP); |
| 1652 |
|
} |
| 1653 |
|
} |
| 1654 |
|
LoadingScene.prototype.addOtherResource = function (identify) { |
| 1655 |
|
this.requestCount++; |
| 1656 |
|
this.otherResourceCount++; |
| 1657 |
|
}; |
| 1658 |
|
LoadingScene.prototype.otherResourceComplete = function (identify) { |
| 1659 |
|
this.otherResources[identify]--; |
| 1660 |
|
this.otherResourceCompleted++; |
| 1661 |
|
this.complete(this.lastCnt); |
| 1662 |
|
}; |
| 1663 |
LoadingScene.prototype.complete = function (cnt) { |
LoadingScene.prototype.complete = function (cnt) { |
| 1664 |
this.shapeP.width = this.game.width * ((this.requestCount - cnt) / this.requestCount); |
this.lastCnt = cnt; |
| 1665 |
|
var per = (this.jgameRequestCount - cnt + this.otherResourceCompleted) / this.requestCount; |
| 1666 |
|
this.shapeP.width = this.game.width * per; |
| 1667 |
this.shapeP.updated(); |
this.shapeP.updated(); |
| 1668 |
if(cnt == 0) { |
if(per == 1) { |
| 1669 |
this.resource.loaded.remove(this, this.complete); |
this.resource.loaded.remove(this, this.complete); |
| 1670 |
this.end(); |
this.end(); |
| 1671 |
|
this.finished.fire(); |
| 1672 |
} |
} |
| 1673 |
}; |
}; |
| 1674 |
return LoadingScene; |
return LoadingScene; |
| 2346 |
if(!loadingScene) { |
if(!loadingScene) { |
| 2347 |
loadingScene = new LoadingScene(this, this.resource); |
loadingScene = new LoadingScene(this, this.resource); |
| 2348 |
} |
} |
| 2349 |
|
loadingScene.finished.handle(this, this.preloadComplete); |
| 2350 |
this.changeScene(loadingScene); |
this.changeScene(loadingScene); |
|
this.resource.loaded.handle(this, this.preloadComplete); |
|
| 2351 |
}; |
}; |
| 2352 |
Game.prototype.preloadComplete = function (cnt) { |
Game.prototype.preloadOther = function (identity) { |
| 2353 |
if(cnt == 0) { |
var loadingScene = this.currentScene; |
| 2354 |
this.loaded.fire(); |
loadingScene.addOtherResource(identity); |
| 2355 |
this.resource.loaded.remove(this, this.preloadComplete); |
}; |
| 2356 |
} |
Game.prototype.preloadCompleteOther = function (identity) { |
| 2357 |
|
var loadingScene = this.currentScene; |
| 2358 |
|
loadingScene.otherResourceComplete(identity); |
| 2359 |
|
}; |
| 2360 |
|
Game.prototype.preloadComplete = function () { |
| 2361 |
|
this.loaded.fire(); |
| 2362 |
}; |
}; |
| 2363 |
Game.prototype.end = function () { |
Game.prototype.end = function () { |
| 2364 |
this.renderer.render(); |
this.renderer.render(); |