[solved] Using of 80 different bullet actors

1MrPaul1

  • *
  • Posts: 1285
My hero shooting with one of 80 different bullets. So before shooting I need to set up "bullet" actor type attribute with one actor from 80 available variations of bullets. We can't use lists for actor types, and i need to set up all actor types manually, I mean i need next code
If "bullet number"=1
Set bullet to "bullet1"
If "bullet number"=2
Set bullet to "bullet2"
If "bullet number"=3
Set bullet to "bullet3"
e.t.c. 80 times...
It makes behavior to large, and also, i'm afraid that it will take to much time to calculating 80 "if" conditions, and this is not good, shooting must be fast. So, may be, it is possible to automate this process and make code shorter?

« Last Edit: March 06, 2012, 09:48:46 am by 1MrPaul1 »

rob1221

  • *
  • Posts: 9474
I don't think you can make that any shorter without code.

Code: [Select]
getActorTypeByName("name")
This is probably what you need but I don't know exactly how you would set it up.

1MrPaul1

  • *
  • Posts: 1285
Thank you very much, i will find the way how to set up it. Only one question, will this code works in xcode in iStencyl?

captaincomic

  • *
  • Posts: 6108
For iOS you would have to
Code: [Select]
[self getActorTypeByName:@"name"]
you can use the <do only in Flash>/<do only in iOS> blocks to make it work on both platforms.

Altough in iOS seems to be tricky to get it right: http://community.stencyl.com/index.php/topic,7895.0.html
If it works for you, please let us know how you did it.

rob1221

  • *
  • Posts: 9474
Yeah I forgot to mention the code I posted is for flash.  For "name", you would use the text "bullet" and add a number to it based on the value of your "bullet number" attribute.

1MrPaul1

  • *
  • Posts: 1285
For iOS you would have to
Code: [Select]
[self getActorTypeByName:@"name"]
you can use the <do only in Flash>/<do only in iOS> blocks to make it work on both platforms.

Altough in iOS seems to be tricky to get it right: http://community.stencyl.com/index.php/topic,7895.0.html
If it works for you, please let us know how you did it.
Thank you, I can't check iOs code now, but it seems that this is almost as in flash, and I think in future I will add it fast.

Yeah I forgot to mention the code I posted is for flash.  For "name", you would use the text "bullet" and add a number to it based on the value of your "bullet number" attribute.
Yeah, I already did it exactly how you mentioned, renamed all bullets in manner ''bullet1", "bullet2", "bullet3" etc than get from list number of bullet and combine it with word "bullet" and it's works great
this is ready png behavior if somebody need it