This site requires JavaScript, please enable it in your browser!
Greenfoot back
MichaelMac
MichaelMac wrote ...

2017/3/9

Want to spawn specific actor based off value of array

MichaelMac MichaelMac

2017/3/9

#
Hi guys, wondering if there was a better way to add an actor to the world based off an array value. I'm rolling dice and then storing the values in an array, I realise you could do this with a considerable amount of "if" statements, but I was wondering if there was another way to do it that would be faster/better.
danpost danpost

2017/3/9

#
It would be difficult to determine if there was a better way or not without some more details and maybe some examples to go along with it.
Nosson1459 Nosson1459

2017/3/9

#
I don't really know what you mean, and I can't see (and probably nor can anyone else) what code there is to make better. I might give you some code for whatever this is that you want, and it won't be faster and/or better because you haven't really showed what you have.
danpost danpost

2017/3/9

#
Since no more information was given, I could only speculate that the actors each represent a dice with a different value. Then, the answer to 'is there a better way' would be "yes" (definitely better from a design perspective; but faster -- as far as coding time, probably; as far as execution time, questionable).
You need to login to post a reply.