Skip to content

Commit

Permalink
Replaced "sharedXXX" with "getInstance"
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoquesada committed Jul 23, 2012
1 parent fc7ebe2 commit 61aba1c
Show file tree
Hide file tree
Showing 129 changed files with 990 additions and 983 deletions.
50 changes: 25 additions & 25 deletions CocosDenshion/SimpleAudioEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cc.capabilities = {
* @class
* @extends cc.Class
*/
cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
_initialized:false,
_supportedFormat:[ "mp3", "ogg", "wav" ],
_requestedFormat:null,
Expand Down Expand Up @@ -86,7 +86,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @return {Boolean}
* @example
* //example
* cc.AudioManager.sharedEngine().init("mp3,ogg");
* cc.AudioEngine.getInstance().init("mp3,ogg");
*/
init:function (audioType) {
if (audioType) {
Expand Down Expand Up @@ -167,7 +167,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {Boolean} loop Whether the background music loop or not.
* @example
* //example
* cc.AudioManager.sharedEngine().playBackgroundMusic(path, false);
* cc.AudioEngine.getInstance().playBackgroundMusic(path, false);
*/
playBackgroundMusic:function (path, loop) {
if (this._bgmList[this._playingBgm]) {
Expand All @@ -184,7 +184,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {Boolean} releaseData If release the background music data or not.As default value is false.
* @example
* //example
* cc.AudioManager.sharedEngine().stopBackgroundMusic();
* cc.AudioEngine.getInstance().stopBackgroundMusic();
*/
stopBackgroundMusic:function (releaseData) {
if (this._bgmList[this._playingBgm]) {
Expand All @@ -199,7 +199,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* Pause playing background music.
* @example
* //example
* cc.AudioManager.sharedEngine().pauseBackgroundMusic();
* cc.AudioEngine.getInstance().pauseBackgroundMusic();
*/
pauseBackgroundMusic:function () {
if (this._bgmList[this._playingBgm]) {
Expand All @@ -210,7 +210,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* Resume playing background music.
* @example
* //example
* cc.AudioManager.sharedEngine().resumeBackgroundMusic();
* cc.AudioEngine.getInstance().resumeBackgroundMusic();
*/
resumeBackgroundMusic:function () {
if (this._bgmList[this._playingBgm]) {
Expand All @@ -222,7 +222,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* Rewind playing background music.
* @example
* //example
* cc.AudioManager.sharedEngine().rewindBackgroundMusic();
* cc.AudioEngine.getInstance().rewindBackgroundMusic();
*/
rewindBackgroundMusic:function () {
if (this._bgmList[this._playingBgm]) {
Expand All @@ -239,7 +239,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @return {Boolean} If is playing return true,or return false.
* @example
* //example
* if (cc.AudioManager.sharedEngine().isBackgroundMusicPlaying()) {
* if (cc.AudioEngine.getInstance().isBackgroundMusicPlaying()) {
* cc.Log("background music is playing");
* }
* else {
Expand All @@ -255,7 +255,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @return {Number}
* @example
* //example
* var volume = cc.AudioManager.sharedEngine().getBackgroundMusicVolume();
* var volume = cc.AudioEngine.getInstance().getBackgroundMusicVolume();
*/
getBackgroundMusicVolume:function () {
if (this._bgmList[this._playingBgm]) {
Expand All @@ -271,7 +271,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {Number} volume Volume must be in 0.0~1.0 .
* @example
* //example
* cc.AudioManager.sharedEngine().setBackgroundMusicVolume(0.5);
* cc.AudioEngine.getInstance().setBackgroundMusicVolume(0.5);
*/
setBackgroundMusicVolume:function (volume) {
if (this._bgmList[this._playingBgm]) {
Expand All @@ -292,7 +292,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @return {Number}
* @example
* //example
* var effectVolume = cc.AudioManager.sharedEngine().getEffectsVolume();
* var effectVolume = cc.AudioEngine.getInstance().getEffectsVolume();
*/
getEffectsVolume:function () {
return this._effectsVolume;
Expand All @@ -303,7 +303,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {Number} volume Volume must be in 0.0~1.0 .
* @example
* //example
* cc.AudioManager.sharedEngine().setEffectsVolume(0.5);
* cc.AudioEngine.getInstance().setEffectsVolume(0.5);
*/
setEffectsVolume:function (volume) {
if (volume > 1) {
Expand All @@ -328,7 +328,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {Boolean} loop Whether to loop the effect playing, default value is false
* @example
* //example
* var soundId = cc.AudioManager.sharedEngine().playEffect(path);
* var soundId = cc.AudioEngine.getInstance().playEffect(path);
*/
playEffect:function (path, loop) {
var soundCache = this._getEffectList(path);
Expand All @@ -344,7 +344,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {String} path The return value of function playEffect.
* @example
* //example
* cc.AudioManager.sharedEngine().pauseEffect(path);
* cc.AudioEngine.getInstance().pauseEffect(path);
*/
pauseEffect:function (path) {
if (this._audioList[path]) {
Expand All @@ -356,7 +356,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* Pause all playing sound effect.
* @example
* //example
* cc.AudioManager.sharedEngine().pauseAllEffects();
* cc.AudioEngine.getInstance().pauseAllEffects();
*/
pauseAllEffects:function () {
if (this._audioList) {
Expand All @@ -371,7 +371,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {String} path The return value of function playEffect.
* @example
* //example
* cc.AudioManager.sharedEngine().resumeEffect(path);
* cc.AudioEngine.getInstance().resumeEffect(path);
*/
resumeEffect:function (path) {
if (this._audioList[path]) {
Expand All @@ -383,7 +383,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* Resume all playing sound effect
* @example
* //example
* cc.AudioManager.sharedEngine().resumeAllEffects();
* cc.AudioEngine.getInstance().resumeAllEffects();
*/
resumeAllEffects:function () {
if (this._audioList) {
Expand All @@ -398,7 +398,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {String} path The return value of function playEffect.
* @example
* //example
* cc.AudioManager.sharedEngine().stopEffect(path);
* cc.AudioEngine.getInstance().stopEffect(path);
*/
stopEffect:function (path) {
if (this._audioList[path]) {
Expand All @@ -411,7 +411,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* Stop all playing sound effects.
* @example
* //example
* cc.AudioManager.sharedEngine().stopAllEffects();
* cc.AudioEngine.getInstance().stopAllEffects();
*/
stopAllEffects:function () {
if (this._audioList) {
Expand Down Expand Up @@ -454,7 +454,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* @param {String} path
* @example
* //example
* cc.AudioManager.sharedEngine().unloadEffect(EFFECT_FILE);
* cc.AudioEngine.getInstance().unloadEffect(EFFECT_FILE);
*/
unloadEffect:function (path) {
if (this._audioList.hasOwnProperty(path)) {
Expand All @@ -473,7 +473,7 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{
* Stop all background music and sound effects
* @example
* //example
* cc.AudioManager.sharedEngine().end();
* cc.AudioEngine.getInstance().end();
*/
end:function () {
this.stopBackgroundMusic();
Expand All @@ -483,11 +483,11 @@ cc.AudioManager = cc.Class.extend(/** @lends cc.AudioManager# */{

/**
* Get the shared Engine object, it will new one when first time be called.
* @return {cc.AudioManager}
* @return {cc.AudioEngine}
*/
cc.AudioManager.sharedEngine = function () {
cc.AudioEngine.getInstance = function () {
if (!cc.sharedEngine) {
cc.sharedEngine = new cc.AudioManager();
cc.sharedEngine = new cc.AudioEngine();
}
return cc.sharedEngine;
};
};
8 changes: 4 additions & 4 deletions Demo/HelloDomMenu/Classes/AppDelegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cc.AppDelegate = cc.Application.extend({
*/
applicationDidFinishLaunching:function () {
// initialize director
var director = cc.Director.sharedDirector();
var director = cc.Director.getInstance();

// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// director->enableRetinaDisplay(true);
Expand All @@ -74,14 +74,14 @@ cc.AppDelegate = cc.Application.extend({
@param the pointer of the application
*/
applicationDidEnterBackground:function () {
cc.Director.sharedDirector().pause();
cc.Director.getInstance().pause();
},

/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
applicationWillEnterForeground:function () {
cc.Director.sharedDirector().resume();
cc.Director.getInstance().resume();
}
});
});
4 changes: 2 additions & 2 deletions Demo/HelloDomMenu/HelloDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ var Helloworld = cc.Layer.extend({
// 1. super init first
this._super();

var size = cc.Director.sharedDirector().getWinSize();
var size = cc.Director.getInstance().getWinSize();

//this.helloLb = cc.LabelTTF.create("Hello World", "Arial", 24);
// position the label on the center of the screen
//this.helloLb.setPosition(cc.ccp(cc.Director.sharedDirector().getWinSize().width / 2, 0));
//this.helloLb.setPosition(cc.ccp(cc.Director.getInstance().getWinSize().width / 2, 0));
// add the label as a child to this layer
//this.addChild(this.helloLb, 5);

Expand Down
2 changes: 1 addition & 1 deletion Demo/NativeClientDemo/cocos2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
s.id = 'cocos2d-html5';
//else if single file specified, load singlefile
});
})();
})();
6 changes: 3 additions & 3 deletions Demo/NativeClientDemo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var cocos2dApp = cc.Application.extend({
this.startScene = scene;
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
cc.setup(this.config['tag']);
cc.AudioManager.sharedEngine().init("mp3,ogg");
cc.AudioEngine.getInstance().init("mp3,ogg");
cc.Loader.shareLoader().onloading = function () {
cc.LoaderScene.shareLoaderScene().draw();
};
Expand All @@ -46,7 +46,7 @@ var cocos2dApp = cc.Application.extend({
},
applicationDidFinishLaunching:function () {
// initialize director
var director = cc.Director.sharedDirector();
var director = cc.Director.getInstance();

// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// director->enableRetinaDisplay(true);
Expand All @@ -65,4 +65,4 @@ var cocos2dApp = cc.Application.extend({
return true;
}
});
var myApp = new cocos2dApp(HelloWorldScene);
var myApp = new cocos2dApp(HelloWorldScene);
14 changes: 7 additions & 7 deletions Demo/NativeClientDemo/src/NativeClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ var Helloworld = cc.Layer.extend({
"CloseSelected.png",
this,
cc.menu_selector(Helloworld.menuCloseCallback) );
closeItem.setPosition( cc.ccp(cc.Director.sharedDirector().getWinSize().width - 20, 20) );
closeItem.setPosition( cc.ccp(cc.Director.getInstance().getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
var menu = cc.Menu.create(closeItem, null);
Expand All @@ -172,7 +172,7 @@ var Helloworld = cc.Layer.extend({
// create and initialize a label
//var pLabel = cc.LabelTTF.create("Hello World", "Arial", 24);
// ask director the window size
var size = cc.Director.sharedDirector().getWinSize();
var size = cc.Director.getInstance().getWinSize();

// position the label on the center of the screen
//pLabel.setPosition( cc.ccp(size.width / 2, size.height - 50) );
Expand All @@ -194,11 +194,11 @@ var Helloworld = cc.Layer.extend({
//this.addChild(helloSprite,0);

this.helloLb = cc.LabelTTF.create("Hello World", "Arial", 24);
this.helloLb.setPosition(cc.ccp(cc.Director.sharedDirector().getWinSize().width / 2, 0));
this.helloLb.setPosition(cc.ccp(cc.Director.getInstance().getWinSize().width / 2, 0));
this.addChild(this.helloLb, 5);

this.sprite = cc.Sprite.create("res/HelloWorld.png");
this.sprite.setPosition(cc.ccp(cc.Director.sharedDirector().getWinSize().width / 2, cc.Director.sharedDirector().getWinSize().height / 2));
this.sprite.setPosition(cc.ccp(cc.Director.getInstance().getWinSize().width / 2, cc.Director.getInstance().getWinSize().height / 2));
this.sprite.setVisible(true);
this.sprite.setAnchorPoint(cc.ccp(0.5, 0.5));
this.sprite.setScale(0.5);
Expand Down Expand Up @@ -284,19 +284,19 @@ var Helloworld = cc.Layer.extend({
cc.canvas.height = 320 * xScale;
cc.renderContext.translate(0, cc.canvas.height);
cc.renderContext.scale(xScale, xScale);
cc.Director.sharedDirector().setContentScaleFactor(xScale);
cc.Director.getInstance().setContentScaleFactor(xScale);
},
// a selector callback
menuCloseCallback:function (sender) {
cc.Director.sharedDirector().end();
cc.Director.getInstance().end();
},
ccTouchesBegan:function (touches, event) {
this.isMouseDown = true;
},
ccTouchesMoved:function (touches, event) {
if (this.isMouseDown) {
if (touches) {
this.circle.setPosition(new cc.Point(touches[0].locationInView().x, touches[0].locationInView().y));
this.circle.setPosition(new cc.Point(touches[0].getLocation().x, touches[0].getLocation().y));
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion HelloHTML5World/cocos2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
s.id = 'cocos2d-html5';
//else if single file specified, load singlefile
});
})();
})();
6 changes: 3 additions & 3 deletions HelloHTML5World/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var cocos2dApp = cc.Application.extend({
this.startScene = scene;
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
cc.setup(this.config['tag']);
cc.AudioManager.sharedEngine().init("mp3,ogg");
cc.AudioEngine.getInstance().init("mp3,ogg");
cc.Loader.shareLoader().onloading = function () {
cc.LoaderScene.shareLoaderScene().draw();
};
Expand All @@ -46,7 +46,7 @@ var cocos2dApp = cc.Application.extend({
},
applicationDidFinishLaunching:function () {
// initialize director
var director = cc.Director.sharedDirector();
var director = cc.Director.getInstance();

// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// director->enableRetinaDisplay(true);
Expand All @@ -65,4 +65,4 @@ var cocos2dApp = cc.Application.extend({
return true;
}
});
var myApp = new cocos2dApp(HelloWorldScene);
var myApp = new cocos2dApp(HelloWorldScene);
8 changes: 4 additions & 4 deletions HelloHTML5World/src/myApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var Helloworld = cc.Layer.extend({
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// ask director the window size
var size = cc.Director.sharedDirector().getWinSize();
var size = cc.Director.getInstance().getWinSize();

// add a "close" icon to exit the progress. it's an autorelease object
var closeItem = cc.MenuItemImage.create(
Expand Down Expand Up @@ -143,19 +143,19 @@ var Helloworld = cc.Layer.extend({
cc.canvas.height = cc.originalCanvasSize.height * xScale;
cc.renderContext.translate(0, cc.canvas.height);
cc.renderContext.scale(xScale, xScale);
cc.Director.sharedDirector().setContentScaleFactor(xScale);
cc.Director.getInstance().setContentScaleFactor(xScale);
},
// a selector callback
menuCloseCallback:function (sender) {
cc.Director.sharedDirector().end();
cc.Director.getInstance().end();
},
ccTouchesBegan:function (touches, event) {
this.isMouseDown = true;
},
ccTouchesMoved:function (touches, event) {
if (this.isMouseDown) {
if (touches) {
//this.circle.setPosition(new cc.Point(touches[0].locationInView().x, touches[0].locationInView().y));
//this.circle.setPosition(new cc.Point(touches[0].getLocation().x, touches[0].getLocation().y));
}
}
},
Expand Down
Loading

0 comments on commit 61aba1c

Please sign in to comment.