Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // There is a bug where I attempt to get an ActorID from an animation that was just remove and is assigned with that ID and then another new animation is added and it's assigned that same ID. I'm not sure if it's a timing thing or if I've made bad code
- //For more information please look at my tweet: https://twitter.com/WinderpTV/status/1345439896299855872?s=20
- var actorsArr = [
- {actorName: "Putt-Putt", actorID:1},
- {actorName: "SomeRadomAnimation1", actorID:2},
- {actorName: "SomeRadomAnimation2", actorID:3}
- ];
- function getNextActorID(){
- var _loc1 = 0;//index
- var _loc2 = 1;//ActorID
- while (true) {
- if(ACTOR ID FROM actorsArr IS IN USE){
- continue;
- }
- //OTHERWISE GIVE ME USABLE ACTOR ID THAT'S NOT FOUND IN actorsArr
- return _loc2;
- }
- //NOTHING TO GIVE
- return -1;
- }
- function addActor(startingCostume, isIdle = false, isPlayer = false, roomOverride = undefined, startFrame = 0, target = undefined, color = ""){
- //GET AVAIBLE ACTOR ID
- //ADD ANIMATION SPRITE BASED ON ACTOR ID
- //What I done to achieve this...
- var _actorID = this.getNextActorID();
- var _index = (this.actors.push(new com.wtv.Test(this, _actorID, isPlayer))) - 1;
- return ({actor:this.actors[_index], actorID:_actorID});
- }// end of the function
- function removeActor(actorID, doSplice = true, removeTarget = true) {
- //REMOVE ACTOR FROM actorsArr BASED ON actorID GIVEN
- //What I done to achieve this...
- var index = this.getActorIndexByID(actorID, 'removeActor2');
- var actor = this.actors[index];
- this.actors.splice(index, 1);
- }// end of the function
Add Comment
Please, Sign In to add comment