Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Joe on Thu 26/02/2009 21:36:38

Title: Overlay with DynamicSprite
Post by: Joe on Thu 26/02/2009 21:36:38
Hello again!

Iv'e got a simple question... well, not so simple...

Is there any way to use a DynamicSprite as an Overlay? so that I can move it in the screen.
Well there is another question: Is there any way to use a DrawingSurface as an Overlay?


Thanks!

EDIT: Ok for DynamicSprite I think I could do this:


DynamicSprite* sprite = DynamicSprite.CreateFromFile("laser.bmp");

Overlay *myol = Overlay.CreateGraphical(1, 1, sprite.Graphic, false);



But I haven't answered my oher question
Title: Re: Overlay with DynamicSprite
Post by: Khris on Thu 26/02/2009 22:03:55
You don't use a DrawingSurface as an Overlay.
If you want to draw something, then use it as an Overlay, you create a DynamicSprite, then draw to its DrawingSurface, release it, then assign the DynSprite to the Overlay.

Think of the DynamicSprite as a picture frame, while the DrawingSurface is its canvas.
Title: Re: Overlay with DynamicSprite
Post by: Joe on Thu 26/02/2009 22:08:22
Thanks for answering.

But how do I do that? Cause the code I guessed didn't give error but it didn't work...
Title: Re: Overlay with DynamicSprite
Post by: Khris on Thu 26/02/2009 22:17:57
You have to declare the pointers outside any function, otherwise they're destroyed as soon as the function finishes.
Title: Re: Overlay with DynamicSprite
Post by: Joe on Thu 26/02/2009 22:29:57
Ok, thanks very much, its working now perfectly, but... can I set the overlay baseline?, so that sometimes the characters walk over the overlay and other times the walk behind...
Title: Re: Overlay with DynamicSprite
Post by: Khris on Thu 26/02/2009 22:50:57
You have to use objects/characters for that sort of thing. Overlays are always displayed above everything else (except GUIs).
Title: Re: Overlay with DynamicSprite
Post by: Joe on Thu 26/02/2009 23:30:22
Ok.

How should I declarate a new object which creates when the player pres a button, moves in the screen and then disappear?

Here is my code, I know it's all screwed up but here it is, (it doesn't work at all):



DynamicSprite* sprite;
Object *obj;


void Make(int x,  int y){

  sprite = DynamicSprite.CreateFromFile("laser.bmp");

  obj.Baseline=70;
  obj.Graphic=sprite.Graphic;
  obj.SetPosition(x, y);
  obj.Visible=true;
  obj.Move(mouse.x, mouse.y, 2, eNoBlock, eAnywhere);

}

Title: Re: Overlay with DynamicSprite
Post by: Khris on Thu 26/02/2009 23:43:38
You can't create objects on the fly, you'll have to use an existing one. If it's supposed to appear in more than one room, use a character instead.
Title: Re: Overlay with DynamicSprite
Post by: Joe on Fri 27/02/2009 01:14:00
Hmm I really don't like the need of creating a character from the editor... Isn't there any other way to do it?

The reason I don't like it is not a whim, it's to get my scripts can turn into universal laws  :P
Title: Re: Overlay with DynamicSprite
Post by: Gilbert on Fri 27/02/2009 01:24:09
Overlay is another choice, but in my opinion it's even more limited compared to using characters. A character is probably the best choice here.
Title: Re: Overlay with DynamicSprite
Post by: Joe on Fri 27/02/2009 01:27:54
If Overlay had baseline support it would be perfect. Bur you really sure there no other possiblity that is not a character??

???

There must be one!!! 
Title: Re: Overlay with DynamicSprite
Post by: Gilbert on Fri 27/02/2009 01:42:41
No, character is definitely the easiest and best way.

Other possibilities are just overlays and raw drawing onto backgrounds (drawing surfaces) which have their limitations and are not as easy to handle, or use some evil plugins if there are any.

There is no reason not to use a dummy character for that (unless you only do this in a few rooms so you can add one object in each of these rooms for this, or when AGS finally enables you to dynamitely create new objects in a room).
Title: Re: Overlay with DynamicSprite
Post by: Trent R on Fri 27/02/2009 09:25:10
Why are you so against using a character? You can just create a char and assign it any random view, and then change it to literally anything you want via script.


~Trent
Title: Re: Overlay with DynamicSprite
Post by: Khris on Fri 27/02/2009 09:37:29
And you don't even need all that DynamicSprite business.
Just create a view with the laser sprite as the first two frames of the first four loops and set it as cLaser's NormalView.
The only thing left to do is to change cLaser's .x, .y and .z.
Title: Re: Overlay with DynamicSprite
Post by: Joe on Fri 27/02/2009 19:27:56
Quote from: Trent R on Fri 27/02/2009 09:25:10
Why are you so against using a character?

Because I'm stupid, and just want to make everything too perfect, and if I don't get it I get really sad and die.

I'm a stupid philosophist.
Title: Re: Overlay with DynamicSprite
Post by: Khris on Fri 27/02/2009 20:25:10
I know how you feel; I also dislike having to publish a GUI along with a module or having the user add something themselves in order for a module to work.

Well, maybe when AGS 4 comes out. :)
Title: Re: Overlay with DynamicSprite
Post by: Trent R on Fri 27/02/2009 20:43:30
I don't mean to say you were stupid, and now I read my post again and it could be taken as rude. I apologize.

But I do totally get where you're coming from. I've deleted and reorganized my inventory items a few times just so that they are perfect..


~Trent
Title: Re: Overlay with DynamicSprite
Post by: Joe on Fri 27/02/2009 20:56:01
Ok thanks for your support, and Trent, please I really didn't want to make you think you offended me, cause you didn't, I just said that because I needed to insult someone, and what a better therapy than insulting myself? Hehe :)

Thanks