Page 1 of 1

Dynamically assign an image to an actor

PostPosted: Fri May 03, 2013 8:30 pm
by zichemak
Im trying to set the image of an actor through code in the Script Editor as follows:

actor1.anim1.file = 'cargun031.png';

but its giving a script error. what is the correct syntax?

Re: Dynamically assign an image to an actor

PostPosted: Fri May 03, 2013 8:55 pm
by skydereign
There isn't a proper syntax for it, as it isn't currently supported. The only way you can do that is to use a canvas actor, read in the image file (easiest with bmp) and draw it on the canvas. This is a lot of work considering all the limitations it can cause so I wouldn't recommend it.

Re: Dynamically assign an image to an actor

PostPosted: Sun May 05, 2013 8:19 pm
by zichemak
skydereign wrote:There isn't a proper syntax for it, as it isn't currently supported. The only way you can do that is to use a canvas actor, read in the image file (easiest with bmp) and draw it on the canvas. This is a lot of work considering all the limitations it can cause so I wouldn't recommend it.


This seems like the way I will have to go about it. How do I do what you've described step by step?

Re: Dynamically assign an image to an actor

PostPosted: Mon May 06, 2013 2:23 am
by skydereign
You seem to want to use jpg as your image type, which makes it significantly harder. bmp is the easiest file type and there are a few examples on the forums on how to do it. I'm currently too busy to guide you step by step, but here's something to get you going. http://game-editor.com/forum/viewtopic.php?f=6&t=5778&p=40393
There are other examples if you search for it, but that link provides a function for loading and drawing out a bmp file.

Re: Dynamically assign an image to an actor

PostPosted: Mon May 06, 2013 8:45 am
by zichemak
Thanks and I also found these video tutorials that show you exactly how to do it:

viewtopic.php?f=27&t=12088&hilit=draw+bmp