Dynamically assign an image to an actor

Non-platform specific questions.

Dynamically assign an image to an actor

Postby zichemak » Fri May 03, 2013 8:30 pm

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?
zichemak
 
Posts: 10
Joined: Mon Apr 29, 2013 6:34 pm
Score: 0 Give a positive score

Re: Dynamically assign an image to an actor

Postby skydereign » Fri May 03, 2013 8:55 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Dynamically assign an image to an actor

Postby zichemak » Sun May 05, 2013 8:19 pm

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?
zichemak
 
Posts: 10
Joined: Mon Apr 29, 2013 6:34 pm
Score: 0 Give a positive score

Re: Dynamically assign an image to an actor

Postby skydereign » Mon May 06, 2013 2:23 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Dynamically assign an image to an actor

Postby zichemak » Mon May 06, 2013 8:45 am

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
zichemak
 
Posts: 10
Joined: Mon Apr 29, 2013 6:34 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron