Confira o Videos Épicos #45!
17 Respostas   449 Visualizações
0 Membros e 1 Visitante estão vendo este tópico.
var allcards = [{name: "Werewolf", atk: 70, def: 30, type:[1,2], atkbuff: 0, defbuff: 0, price: 60}];var allcoins = [{name: "Ilha", type: 0, mapstrongness[0], mapweakness:[2], atkbuff: 200, defbuff: 200, backgroundpicture: "Camp Island", coinpicture: "Coin Island", bgm: ["Town1", 90, 100, 0], bgs: ["Sea", 70, 100, 0], price: 110}, {name: "Espaço", type: 0, mapstrongness[1], mapweakness:[0,2,3], atkbuff: 200, defbuff: 200, backgroundpicture: "Camp Space", coinpicture: "Coin Space", bgm: ["Dungeon1", 50, 100, 0], bgs: ["", 0, 0, 0], price: 210}];
function Coinchange() { if (allcoins[activecoin].type == 0) { for(i = 0; i < 3 ; i++) { for (j = 0; j < allcoins[activecoin].mapstrongness.length - 1; j++) { if (allcards[enemycards[i]].type.indexOf(j) !== -1) { allcards[enemycards[i]].atkbuff = allcoins[activecoin].atkbuff; allcards[enemycards[i]].defbuff = allcoins[activecoin].defbuff; }; if (allcards[playercards[i]].type.indexOf(j) !== -1) { allcards[playercards[i]].atkbuff = allcoins[activecoin].atkbuff; allcards[playercards[i]].defbuff = allcoins[activecoin].defbuff; }; }; for (j = 0; j < allcoins[activecoin].mapweakness.length - 1; j++) { if (allcards[enemycards[i]].type.indexOf(j) !== -1) { allcards[enemycards[i]].atkbuff = -allcoins[activecoin].atkbuff; allcards[enemycards[i]].defbuff = -allcoins[activecoin].defbuff; } if (allcards[playercards[i]].type.indexOf(j) !== -1) { allcards[playercards[i]].atkbuff = -allcoins[activecoin].atkbuff; allcards[playercards[i]].defbuff = -allcoins[activecoin].defbuff; }; }; }; $gameScreen.showPicture(1, allcoins[activecoin].backgroundpicture, 0, 0, 0, 100, 100, 255, 0) $gameScreen.showPicture(17, allcoins[activecoin].coinpicture, 0, 409, 331, 100, 100, 255, 0); var mapbgm = { name: allcoins[activecoin].bgm[0], volume: allcoins[activecoin].bgm[1],pitch: allcoins[activecoin].bgm[2], pan: allcoins[activecoin].bgm[3]}; var mapbgs = { name: allcoins[activecoin].bgs[0], volume: allcoins[activecoin].bgs[1],pitch: allcoins[activecoin].bgs[2], pan: allcoins[activecoin].bgs[3]}; AudioManager.playBgm(mapbgm); AudioManager.playBgs(mapbgs); };};
Coinchange() is not defined
mapstrongness: [0],
Coinchange(this._params[0])
Cannot read property 'type' of undefined
var allcards = [{name: "Werewolf", atk: 70, def: 30, type:[1,2], atkbuff: 0, defbuff: 0, price: 60}];var allcoins = [{name: "Ilha", type: 0, mapstrongness:[0], mapweakness:[2], atkbuff: 200, defbuff: 200, backgroundpicture: "Camp Island", coinpicture: "Coin Island", bgm: ["Town1", 90, 100, 0], bgs: ["Sea", 70, 100, 0], price: 110}, {name: "Espaço", type: 0, mapstrongness:[1], mapweakness:[0,2,3], atkbuff: 200, defbuff: 200, backgroundpicture: "Camp Space", coinpicture: "Coin Space", bgm: ["Dungeon1", 50, 100, 0], bgs: ["", 0, 0, 0], price: 210}];
var deposito = new Object() // ou simplesmente {}
deposito["identificador"] = meuObjeto;
Ah sim, quando você declara eles via eventos (chamar script), eles só existem naquele momento, depois deixam de existir, sendo deletadas da memória.O sábio seria fazer uma variável que fosse guardando elas na memória, tipo algo parecido com isso:Código: [Selecionar]var deposito = new Object() // ou simplesmente {}Daí no chamar script, você poderia usar:Código: [Selecionar]deposito["identificador"] = meuObjeto;E você pode acessar via qualquer lugar aquele objeto que foi criado pelo evento.
var allcards = new Object();var allcoins = new Object();var allcards = [{name: "Werewolf", atk: 70, def: 30, type:[1,2], atkbuff: 0, defbuff: 0, price: 60}];var allcoins = [{name: "Ilha", type: 0, mapstrongness:[0], mapweakness:[2], atkbuff: 200, defbuff: 200, backgroundpicture: "Camp Island", coinpicture: "Coin Island", bgm: ["Town1", 90, 100, 0], bgs: ["Sea", 70, 100, 0], price: 110}, {name: "Espaço", type: 0, mapstrongness:[1], mapweakness:[0,2,3], atkbuff: 200, defbuff: 200, backgroundpicture: "Camp Space", coinpicture: "Coin Space", bgm: ["Dungeon1", 50, 100, 0], bgs: ["", 0, 0, 0], price: 210}];
"use strict"; // Sim, eu programo no strict mode.class Card { constructor () { // Isso é a mesma coisa do initialize do ruby. this.name = "Werewolf"; this.atk = 70; this.def = 30; this.type = [1, 2]; this.atkbuff = 0; this.defbuff = 0; this.price = 60; };};var card1 = new Card();console.log(card1.name) // Werewolfvar card2 = new Card();card2.name = "Robot";console.log(card2.name) // Robot
function Card () { this.name = "Werewolf";};var card1 = new Card();console.log(card1.name) // "Werewolf"var card2 = new Card();card2.name = "Robot";console.log(card2.name) // "Robot"
const Card = function () { this.name = "Werewolf";};Object.defineProperty(Card, "name", { get: function () { return this.name }, set: function (value) { this.name = value }});var card1 = new Card();console.log(card1.name) // "Werewolf"var card2 = new Card();card2.name = "Robot";console.log(card2.name) // "Robot"
allcards = []allcars[0] = {this.name = "Werewolf"; this.atk = 70; this.def = 30; this.type = [1, 2]; this.atkbuff = 0; this.defbuff = 0; this.price = 60;}
array[posição].nome
var allCards = [ { name: "Werewolf", atk: 70 }, { name: "Robot", atk: 20 }];console.log(allCards[0].name);
activecoin = 0Coinchange()