Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

added various functions #76

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/model/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@
this.dirty= true;
return this;
},
flipX : function() {
this.setScale(-this.scaleX,this.scaleY);
},
getAnchorPercent : function( anchor ) {

var anchors=[
Expand Down Expand Up @@ -761,6 +764,16 @@

return this;
},
setFullBounds : function(director) {
this.x = 0;
this.y = 0;
this.width = director.width;
this.height = director.height;

this.dirty = true;

return this;
},
/**
* This method sets the position of an Actor inside its parent.
*
Expand Down Expand Up @@ -1139,6 +1152,16 @@

return this;
},
disableDrag : function() {

this.mouseEnter= function(mouseEvent) {};
this.mouseExit = function(mouseEvent) {};
this.mouseMove = function(mouseEvent) {};
this.mouseUp = function(mouseEvent) {};
this.mouseDrag = function(mouseEvent) {};

return this;
},
/**
* Default mouseClick handler.
* Mouse click events are received after a call to mouseUp method if no dragging was in progress.
Expand Down Expand Up @@ -2355,6 +2378,9 @@
getNumActiveChildren : function() {
return this.activeChildren.length;
},
shuffleChildrens : function() {
this.childrenList.sort(function() { return Math.round(Math.random())-0.5; });
},
/**
* Returns the Actor at the iPosition(th) position.
* @param iPosition an integer indicating the position array.
Expand Down Expand Up @@ -2393,6 +2419,12 @@
cl.splice( index, 0, nActor[0] );
}
}
},
setRandomZOrder : function() {
var cl = this.childrenList;
for(var i=0;i<cl.length;i++) {
this.setZOrder(cl[i],Math.floor(Math.random() * (cl.length - 0 + 1) + 0));
}
}
};
/*
Expand Down
5 changes: 4 additions & 1 deletion src/model/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
* @param id {object} an object identifying a sound in the sound cache.
* @return this.
*/
play : function( id ) {
play : function( id, callback ) {
if ( !this.fxEnabled ) {
return this;
}
Expand All @@ -291,6 +291,9 @@
var channel= this.channels.shift();
channel.src= audio.src;
channel.load();
channel.addEventListener('ended', function() {
if(typeof(callback) === "function") callback();
});
channel.volume= audio.volume;
channel.play();
this.workingChannels.push(channel);
Expand Down
4 changes: 2 additions & 2 deletions src/model/director.js
Original file line number Diff line number Diff line change
Expand Up @@ -1320,8 +1320,8 @@
* Plays the audio instance identified by the id.
* @param id {object} the object used to store a sound in the audioCache.
*/
audioPlay : function(id) {
this.audioManager.play(id);
audioPlay : function(id,callback) {
this.audioManager.play(id,callback);
},
/**
* Loops an audio instance identified by the id.
Expand Down