Help drawing individual frames from an actors sequence

You must understand the Game Editor concepts, before post here.

Help drawing individual frames from an actors sequence

Postby Techdojo » Tue Jul 24, 2007 3:21 pm

Hi there,

I'm trying to draw indivdiual frames from a Normal Actors animation sequence in the draw event of a Canvas Actor.

Basically I have a Normal Actor that contains 16 seperate frames and I want to be able to choose which one to draw and where - there's going to be loads of these on screen so I don't want to duplicate or clone the actors.

I found the draw_from() function in the script reference and this works OK, except it only draws the current frame (I've called the ChangeAnimation() function in the create event for various actors concerned to stop the animation from running in the background).

Is there some way to force the current frame number so I can use the draw_from() function, or failing that is there an easy way to include and draw a simple sprite as a resource?

I think I must be missing something simple but I'll be buggered if I can see it... :(

Thanks in advance

Jon...
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby metal_pt » Tue Jul 24, 2007 11:07 pm

You can choose the animation frame with animpos.

in a draw actor event:
animpos=3; // animpos goes from 0 to number of frames-1

Hope it helps
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby Techdojo » Wed Jul 25, 2007 8:25 am

metal_pt wrote:You can choose the animation frame with animpos.

in a draw actor event:
animpos=3; // animpos goes from 0 to number of frames-1

Hope it helps


Sorry if this sounds like a total noob reply - but I need to be able to change the frame fom a different actor.

I have a normal actor called sprites, and a canvas actor called screen.

In the "screen" draw event I call

draw_from("sprites",x,y,1.0);

repeatedly, but I need to change the animpos of "sprites" between calls.

I thought about getting a reference to sprites (by calling CreateActor) in the screen create event, but I couldn't get this to compile, can someone post a quick example please?

Cheers

Jon...
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby DilloDude » Wed Jul 25, 2007 9:35 am

You can use sprites.animpos to change another actor. Of course, if you have clones, you will need to use the getclone function to access clones individually.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Techdojo » Wed Jul 25, 2007 10:33 am

DilloDude wrote:You can use sprites.animpos to change another actor. Of course, if you have clones, you will need to use the getclone function to access clones individually.


But sprites is the name of the actor and you have to reference it in quotes, and "sprites".animpos = 0; returned a compile error (not surprisingly).

So am I right in thinking the only way to do it would be to store the return value from the CreateActor() function into a var of type Actor * and then reference it through that?

Jon...
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby metal_pt » Wed Jul 25, 2007 10:40 am

You should't use the quotes on the actor name.
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby Techdojo » Wed Jul 25, 2007 10:51 am

So is an actors name actually defined as a variable of type Actor ???

D'oh! - I only put it in quotes because the draw_from() function says the first paramter is a pointer to a char string and I assumed that GE references all of it's actors by name...

Hmm, that doesn't seem to be explained very well in the docs...

But thanks for your help

Jon...
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby Techdojo » Wed Jul 25, 2007 11:02 am

Ok it kinda works now (not putting the actor name in quotes)
but here's the Draw Actor script from my background Canvas Actor

Code: Select all
erase(0,0,0,1.0);

draw_from("TitleImg",160,80,1.0);

large_pipes.animpos = 0;
draw_from("large_pipes",20,20,1.0);

large_pipes.animpos = 1;
draw_from("large_pipes",20,60,1.0);

large_pipes.animpos = 2;
draw_from("large_pipes",20,100,1.0);

large_pipes.animpos = 15;
draw_from("large_pipes",20,140,1.0);



The weird thing now is that all of the pipes are all drawn with the same frame (frame 15) ????

Is there not an easy way to be able to draw a series of individual frames from an animation sequence on the screen or am I going to have to have a seperate object for each frame ?????

Jon...
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby DilloDude » Wed Jul 25, 2007 12:41 pm

The animation won't update until the next frame, so changing the animpos and then using draw_from won't work, unless you use draw_from in the next frame (i think). It may be best to use one actor, and set animpos based on cloneindex. Of course, it's not so nice, but... Whilst draw_from is a useful tool, I'd like it if there were more options for it, maybe being able to select an animaion and frame for it. Especially since you have to have an existing actor for it to work.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Wed Jul 25, 2007 12:50 pm

Techdojo wrote:So is an actors name actually defined as a variable of type Actor ???

D'oh! - I only put it in quotes because the draw_from() function says the first paramter is a pointer to a char string and I assumed that GE references all of it's actors by name...

Hmm, that doesn't seem to be explained very well in the docs...

But thanks for your help

Jon...

With the actor's name by itself, it refers to a struct variable. This is only the first clone, however. In functions you use a string (in quotes) which allows you to use clones as well. IF you want to access a particular clone, use the getclone function. It takes a string, and it returns a pointer to the actor's struct:
Code: Select all
Actor * AC = getclone("MyActor.3");
AC->x += 5;
AC->yvelocity *= .99;

A little off the topic, but I hope it helps.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Techdojo » Wed Jul 25, 2007 1:34 pm

Thanks for that - I kinda thought that was happening.
I ended up having to make 40 clones of my object (for an 8x5 grid) and then during a create event calling the get clone function and storing the address in an array of Actor *'s (and it's still not working the way I want)

I'm sure GE is great for some things, but trying to draw a simple 2D grid of sprites that can change as the player clicks on them seems to be beyond it's capabilities *sheesh*

I think thing's would be a lot easier if the doc's and examples were better, the docs are seriously lacking and although the animated examples show you what to do, they don't explain WHY or what other caveats exist!

:( Jon...
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby Sgt. Sparky » Wed Jul 25, 2007 3:38 pm

if you want your pipes all different animations that never change you should just tile your actors. :D
(but if you are making a game with switching pipes do not tile them.)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby DocRabbit » Wed Jul 25, 2007 6:06 pm

Check here, I posted this in your other question but I think they are about the same.

http://game-editor.com/forum/tp-3950-Ye ... that-.html

Graphics for animation frames are one color blocks, but you can see the idea with them. They change on a mouse click.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest