Created
December 7, 2012 15:01
-
-
Save grifdail/4233789 to your computer and use it in GitHub Desktop.
bug bizare JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Data.Building = [] | |
Data.Building[0] = { | |
image: (new Image()),//.src="Assets/tree.png", | |
printX: 0, | |
printY: 32, | |
printW: 32, | |
printH: 64, | |
map: [1], | |
width: 1, | |
height: 1, | |
// action | |
actionList: ["chop"], // un array de la liste des actions | |
action: { //La liste des action | |
chop: function() { | |
console.log(this) | |
this.destroy() | |
} | |
} | |
} | |
function Building (x,y,type) { | |
this.type = type; | |
this.data = Data.Building[type]; | |
this.do = function() { | |
console.log(this.data.action) | |
} | |
} | |
/* | |
depuis la console, sur un object Building | |
>> arbre.do() | |
affiche | |
["chop"] | |
mais quands un autre objet lance (ou meme, a la fin du constructeur) | |
arbre.do(); | |
ca afiche | |
[] | |
POURQUOI ?! | |
je presice que je ne touche que a la variable this.data.action (et Data.Building) que a cette endroit | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment