BuildPath.prototype.resetPathButtons = function () {
pathButs = DozerLeft.findByName('buttonsPossiblePath').children;
console.log('new destroy', pathButs.length);
pathButs.forEach( but => {
if (!but.name.includes('Def')){
but.destroy();}
});
pathButs = DozerRight.findByName('buttonsPossiblePath').children;
pathButs.forEach( but => {
if (!but.name.includes('Def')){ but.destroy();}
});
DozerLeft.findByName('buttonsPossiblePath').children.forEach(leftBut => console.log(leftBut.name));
console.log('after destroy', pathButs.length);
if ( DozerLeft.findByName('buttonsPossiblePath').children.length > 4){ this.resetPathButtons();}
};
solved the Issue with a recursive call ⦠but i hate that ā¦
what I`ve done wrong?
as You see Iāve log the result for every call⦠the last child will never get destroyed?
Depending on the random map the possible way points can rise to about a hundret, that still ok for performance, but I`d like to reduce quick fixes in my code, learn what I did wrong and doesent have any recursive , likely possible dangerous code in my codeā¦
if(help) { graditude( āthanxā);}
PS: The Buttons starting with āDefā are default Buttons Iāll need in the next fuction call.
> if ( DozerLeft.findByName('buttonsPossiblePath').children.length > 4){ this.resetPathButtons();}
there are 4 Def Buttons DefLeft , DefRight , DefUp and DefDownā¦
project: PlayCanvas | HTML5 Game Engine
editor: PlayCanvas | HTML5 Game Engine
theres a much bigger issue: involving gamePad/controller I
d like to delay that isssue, still prototype is basically workingā¦
pps: the PathButton script doesnāt exist right now, but it will have element.on (thouch and mouse event)
any suggesetions how to handle that are verry welcomeā¦
I belive Iām, still prototyping and have lots of unkilled event handlers