Hi as i describe, i put nodes into the node pool but then when i try to get them out there re none in there
createGameScoreBoardEntry: function(entry){
// create an individual entry
console.log('makeing it now');
// add 1 to the entry count
this.ScoreBoardEntryCount++;
this.PlayerScoreBoardEntry[this.ScoreBoardEntryCount] = [];
// instantiate the entry and save it to an array
this.PlayerScoreBoardEntry[this.ScoreBoardEntryCount]['entry'] = cc.instantiate(this.PlayerScoreBoardEntryPrefab);
// set the tag of the entry
this.PlayerScoreBoardEntry[this.ScoreBoardEntryCount]['entry'].setTag(this.ScoreBoardEntryCount);
this.deSpawnGameScoreBoardEntry(this.ScoreBoardEntryCount);
this.PopulateGameBoardEntry(entry);
console.log('made it with tag'+this.ScoreBoardEntryCount);
},
deSpawnGameScoreBoardEntry: function(tag){
// despawn a monster
console.log('despawning'+tag);
// put the monster back into the pool
this.ScoreBoardEntryPool.put(this.PlayerScoreBoardEntry[tag]['entry']);
console.log('pool size = '+this.ScoreBoardEntryPool.length);
},
spawnGameScoreBoardEntry: function(tag){
// add the passed monster to the GameStage
this.endGameHighScoreScene.addChild(this.PlayerScoreBoardEntry[tag]['entry']);
},
PopulateGameBoardEntry: function( entry){
console.log('l');
console.log(entry);
if(this.ScoreBoardEntryPool.length > 0){
//there are pooled entries to reuse
// get this monster
var thisScoreBoardEntry = this.ScoreBoardEntryPool.get();
// get the monster tag
var thisScoreBoardEntryTag = thisScoreBoardEntry.getTag();
console.log('pool release entry tag = '+thisScoreBoardEntryTag);
// set the monster to an array
this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['entry'] = thisScoreBoardEntry;
// set the Rank var
this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['RankLabel'] = this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['entry'].getChildByName("PlayerScoreBoardRankLabel").getComponent(cc.Label);
// set the Score var
this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['ScoreLabel'] = this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['entry'].getChildByName("PlayerScoreBoardScoreLabel").getComponent(cc.Label);
// set the Rank label for this entry
this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['RankLabel'].string = entry.getRank();
// set the Score label for this entry
this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['ScoreLabel'].string = entry.getFormattedScore();
// get the photo of this entry
var photoUrl = entry.getPlayer().getPhoto();
// set the Photo for this entry
cc.loader.load(photoUrl, (err, texture) => {
this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['entry'].getComponentInChildren(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
});
// if its the first place set the x pos
if(entry.getRank() == 1){
// its first place set the x pos
this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['entry'].y = -20 ;
}else{
//its NOT first place set the x pos
this.PlayerScoreBoardEntry[thisScoreBoardEntryTag]['entry'].y = (i * 100) * -1;
}
this.spawnGameScoreBoardEntry(thisScoreBoardEntryTag);
return;
}else{
console.log('make 1');
this.createGameScoreBoardEntry(entry);
return;
}
}
create a never ending loop that crashes the game. Even though i am putting the nodes into the pool they just arn’t there for some reason.
this is the output i get repeated
l
project.dev.js:499 n {$LeaderboardEntry1: 945, $LeaderboardEntry2: “945”, $LeaderboardEntry5: 1, $LeaderboardEntry3: “”, $LeaderboardEntry4: 1522694773, …}
project.dev.js:517 make 1
project.dev.js:479 makeing it now
project.dev.js:489 despawning1
project.dev.js:491 pool size = undefined