- Joined
- Mar 28, 2016
- Messages
- 1,623
- Reaction score
- 1,439
- First Language
- French
- Primarily Uses
- RMMV
hi
am try to understand a basic notion in JavaScript.
If somebody has some clarification.
if i has this.
//example: i have storing a default permanente array value with a constructor in: $gameSystem.huds.hudsSlot.default = [10,5];
console.log($gameSystem.huds.hudsSlot.default); // return me [10,5]; is nice
//now in a context, i need to store this value in temps var to do some stuff
var test = $gameSystem.huds.hudsSlot.default;
console.log(test): // return me [10,5]; is nice
// but after, if i do
test[0]++;
// or
test[0]+=1;
console.log(test[0]); // return me 11 ( is ok ) !
//But why
console.log($gameSystem.huds.hudsSlot.default) // return me 11 ??????
// why test[0]++; or test[0]+=1; increase my objets $gameSystem.huds.hudsSlot.default ???
// why increase my var test[0] increase $gameSystem.huds.hudsSlot.default[0] in same time ?
thanks a lot for help me
my full context is thats
am try to understand a basic notion in JavaScript.
If somebody has some clarification.
if i has this.
//example: i have storing a default permanente array value with a constructor in: $gameSystem.huds.hudsSlot.default = [10,5];
console.log($gameSystem.huds.hudsSlot.default); // return me [10,5]; is nice
//now in a context, i need to store this value in temps var to do some stuff
var test = $gameSystem.huds.hudsSlot.default;
console.log(test): // return me [10,5]; is nice
// but after, if i do
test[0]++;
// or
test[0]+=1;
console.log(test[0]); // return me 11 ( is ok ) !
//But why
console.log($gameSystem.huds.hudsSlot.default) // return me 11 ??????
// why test[0]++; or test[0]+=1; increase my objets $gameSystem.huds.hudsSlot.default ???
// why increase my var test[0] increase $gameSystem.huds.hudsSlot.default[0] in same time ?
thanks a lot for help me
my full context is thats
my call constructor at boot game
$gameSystem.huds = new huds(); // build the $gameSystem +
and
the builder function call
/*=============================================================================
* BUILD HUDS INTEGRER (not the menue)
=============================================================================*/
// parrent call from $gameSystem.huds = new HUDS();
function huds() {
this.status = false; // tous les huds visible ou non ? supprime tous image
this.modeCine = false // function qui passe en mode cinema
this.hudstates = new hudstates();
this.hudsSlot = new hudsSlot();
}
//sub from parent
//-----------------------------------------------------------------------------
// le huds des stats -----------------
function hudstates() {
this.status = false; // si visible ou non ?
}
// le huds des itemdice.. hudsSlot -------------------
// $gameSystem.huds.hudsSlot
function hudsSlot() {
this.PIDdebug = [15,47]; // static
this.status = false; // si visible ou non ?
this.XY = [25,0]; // default x y screen // change selon les mode de this.movemode
this.easing = []; // store ici tous les processus de easing
this.SlotXY = [[this.XY[0]+37,this.XY[1]+101],[this.XY[0]+37,this.XY[1]+207],[this.XY[0]+37,this.XY[1]+313],[this.XY[0]+37,this.XY[1]+420],[this.XY[0]+37,this.XY[1]+530],
[this.XY[0]+147,this.XY[1]+101],[this.XY[0]+147,this.XY[1]+207],[this.XY[0]+147,this.XY[1]+313],[this.XY[0]+147,this.XY[1]+420],[this.XY[0]+147,this.XY[1]+530]]; // position des 10 slot item,dice default
this.movemode = function(mode) { if (mode==='default') {this.XY = [25,0]; return this.XY}else if (mode==='tuto') {this.XY = [150,20]; return this.XY}else if (mode==='combat') {this.XY = [25,50]; return this.XY}else if (mode==='hide') {this.XY = [-200,0]; return this.XY} } // defeni this.XY sur le bon mode et return linformation
this.slots = []; // initialise build .slot
for (var s =0; s<10; s++) { this.slots = new slots() } // les sub slot du jeux, 10 max
}
// $gameSystem.huds.hudsSlot.slots[]
function slots(id) {
this.pintype = null; // un slot est piner ? si oui quel type ?
this.idcontent = 1; // si contient un id item ?
}
_______________________________________________________________________
After if i try stuff ex:
$gameSystem.huds = new huds(); // build the $gameSystem +
and
the builder function call
/*=============================================================================
* BUILD HUDS INTEGRER (not the menue)
=============================================================================*/
// parrent call from $gameSystem.huds = new HUDS();
function huds() {
this.status = false; // tous les huds visible ou non ? supprime tous image
this.modeCine = false // function qui passe en mode cinema
this.hudstates = new hudstates();
this.hudsSlot = new hudsSlot();
}
//sub from parent
//-----------------------------------------------------------------------------
// le huds des stats -----------------
function hudstates() {
this.status = false; // si visible ou non ?
}
// le huds des itemdice.. hudsSlot -------------------
// $gameSystem.huds.hudsSlot
function hudsSlot() {
this.PIDdebug = [15,47]; // static
this.status = false; // si visible ou non ?
this.XY = [25,0]; // default x y screen // change selon les mode de this.movemode
this.easing = []; // store ici tous les processus de easing
this.SlotXY = [[this.XY[0]+37,this.XY[1]+101],[this.XY[0]+37,this.XY[1]+207],[this.XY[0]+37,this.XY[1]+313],[this.XY[0]+37,this.XY[1]+420],[this.XY[0]+37,this.XY[1]+530],
[this.XY[0]+147,this.XY[1]+101],[this.XY[0]+147,this.XY[1]+207],[this.XY[0]+147,this.XY[1]+313],[this.XY[0]+147,this.XY[1]+420],[this.XY[0]+147,this.XY[1]+530]]; // position des 10 slot item,dice default
this.movemode = function(mode) { if (mode==='default') {this.XY = [25,0]; return this.XY}else if (mode==='tuto') {this.XY = [150,20]; return this.XY}else if (mode==='combat') {this.XY = [25,50]; return this.XY}else if (mode==='hide') {this.XY = [-200,0]; return this.XY} } // defeni this.XY sur le bon mode et return linformation
this.slots = []; // initialise build .slot
for (var s =0; s<10; s++) { this.slots
}
// $gameSystem.huds.hudsSlot.slots[]
function slots(id) {
this.pintype = null; // un slot est piner ? si oui quel type ?
this.idcontent = 1; // si contient un id item ?
}
_______________________________________________________________________
After if i try stuff ex:
Code:
var x = $gameSystem.huds.hudsSlot.PIDdebug //
console.log(x); // return me [25,0];
// but if i do after
x[0]++;
// the $gameSystem.huds.hudsSlot.PIDdebug[0] are increase
//but $gameSystem.huds.hudsSlot.PIDdebug[0] are supose to be static ?!
//What I would like. Did I get it wrong?
Last edited by a moderator:



