Type Mismatch using rawdraw functions- *ViewFrame to Int (solved)

Started by Sparky, Wed 11/04/2007 01:33:45

Previous topic - Next topic

Sparky

Thanks for answering my previous question so quickly. This one is probably just a syntax error as well:
Code: ags
// ints n, x, and y are set above;
ViewFrame *current_frame = Game.GetFrameCountForLoop;
current_frame = (current_frame + n); // error points here
RawDrawImage(x, y, current_frame);
The compiler says "Cannot convert *ViewFrame to int." I was hoping there was something like "FloatToInt" that I could use here, but I'm at a loss, and a forum search for ViewFrame didn't yield any relevant results.

I would just use Object.Animate, but this is for a RawDrawImage call.

For reference this script snippet was working before the addition of Game.GetFrameCountForLoop. It looked like this:
Code: ags
//ints n, x, and y are set above
int current_frame = 234;
current_frame = (current_frame + n);
RawDrawImage(x, y, current_frame);

Ashen

Use the ViewFrame.Graphic property to get the int value (the spriteslot of the frame), e.g.:
Code: ags

int currframe = current_frame.Graphic + n;
RawDrawImage(x, y, currframe); // This also needs an int, not a ViewFrame


However, I'm not sure what you're doing with (the ViewFrame declaration)  - you need to specify a View and Loop to get the count for, and even then it'll only return an int value, not a Frame. What are you trying to do?

EDIT:
Maybe something like:
Code: ags

ViewFrame *current_frame = Game.GetViewFrame(ViewX, LoopX, Game.GetFrameCountForLoop(ViewX, LoopX)-1);

Which will get the sprite for the last frame of LoopX in ViewX, and can be used with the int code above?
I know what you're thinking ... Don't think that.

Sparky

Quote from: Ashen on Wed 11/04/2007 01:49:40
However, I'm not sure what you're doing with (the ViewFrame declaration)  - you need to specify a View and Loop to get the count for, and even then it'll only return an int value, not a Frame. What are you trying to do?

My apologies for the communication error, I don't have the script on hand at this computer and I'm reconstructing it as best I can. The line in question should read
Code: ags
Game.GetFrameCountForLoop(myview, myloop);
where myview and myloop are previously set values.

As for functionality, this is part of a particle system. The system automatically sets up emitters based on room objects. Different emitters use different animated particle sprites. Let's say one uses view 33, loop 3 and another uses view 34, loop 1. This portion of the script draws a single particle using the correct loop and frame. I hope that's enough information to clarify.

Thanks for your suggestions, I'll tinker with the script some more and post a response once I've made more progress or found a solution.

Sparky

Thanks for your help Ashen, everything is up and running now. Here's the finished code snippet including the lines I posted before. Again, I'm sorry my limited internet access posed a communication difficulty.
Code: ags
ViewFrame *initial_frame = Game.GetViewFrame(particles[n].view, particles[n].loop, 0); //get the first frame in the specified loop
int frame_spread = (Game.GetFrameCountForLoop(particles[n].view, particles[n].loop) ); // get the frame count in the loop
float timer_percent = (1.0 - (particles[n].timer / particles[n].lifespan)); // get a fraction for particle animation
int current_frame = (initial_frame.Graphic + FloatToInt(timer_percent * IntToFloat(frame_spread)));
RawDrawImage(FloatToInt(particles[n].x), FloatToInt(testy_bits[n].y), current_frame);


And here are a couple of screenshots of how the system works... the test particles are ugly as sin (just scaling, jagged edged blobs of pure color). The finished game intends to be more polished.


The user creates new objects and sets the appropriate icon...


When the game runs, the script creates appropriate emitters at the object locations.

There's no object level scripting involved. The goal is to make it easy to create and modify scenes with multiple emitters. Thanks again, Ashen!

SMF spam blocked by CleanTalk