Overlay with DynamicSprite

Started by Joe, Thu 26/02/2009 21:36:38

Previous topic - Next topic

Joe

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:
Code: ags


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

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



But I haven't answered my oher question
Copinstar © Oficial Site

Khris

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.

Joe

Thanks for answering.

But how do I do that? Cause the code I guessed didn't give error but it didn't work...
Copinstar © Oficial Site

Khris

You have to declare the pointers outside any function, otherwise they're destroyed as soon as the function finishes.

Joe

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...
Copinstar © Oficial Site

Khris

You have to use objects/characters for that sort of thing. Overlays are always displayed above everything else (except GUIs).

Joe

#6
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):

Code: ags


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);

}

Copinstar © Oficial Site

Khris

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.

Joe

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
Copinstar © Oficial Site

Gilbert

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.

Joe

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!!! 
Copinstar © Oficial Site

Gilbert

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).

Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

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.

Joe

#14
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.
Copinstar © Oficial Site

Khris

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. :)

Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Joe

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
Copinstar © Oficial Site

SMF spam blocked by CleanTalk