My questions...

Started by FanOfHumor, Sat 23/04/2022 15:47:39

Previous topic - Next topic

FanOfHumor

It seems that I am going to be asking many simple questions that don't deserve a topic.So I thought I could just ask them here whenever I need to.


So the first question is:
Is there a way to create an animation and then delete it once its finished.I tried using overlays and dynamicsprites but those don't work as well as objects. I heard somewhere that you can't delete objects.So is there another way?
Second question:
Does the mere existence of an object in a room effect game speed at all? Even if its not visible?

Crimson Wizard

#1
Quote from: Pajama Sam on Sat 23/04/2022 15:47:39
Is there a way to create an animation and then delete it once its finished.I tried using overlays and dynamicsprites but those don't work as well as objects. I heard somewhere that you can't delete objects.So is there another way?

Using room objects or characters: make them hidden by default, make visible when necessary, play animation and hide again.
If this is the effect that happens alot in different rooms - then character is a better choice. Objects have Visible flag, Characters don't for some weird reason, but you can set character to a non-existing room when it's no longer needed (e.g. Char1.ChangeRoom(-1)).


Quote from: Pajama Sam on Sat 23/04/2022 15:47:39
Does the mere existence of an object in a room effect game speed at all? Even if its not visible?

No.

FanOfHumor


FanOfHumor

When making functions how would a parameter be made as optional?

Crimson Wizard

Quote from: Pajama Sam on Sun 24/04/2022 04:20:17
When making functions how would a parameter be made as optional?

You tell it a default value in the function declaration:
Code: ags

function func(int a = 10);

FanOfHumor

This keeps giving me an error(Invalid use of '*').What's the problem?

String* text=text.Append("eOnce");

Khris

You don't need an asterisk when declaring a String.
Also you are using the  text  variable, which you are declaring here, as if it already existed. What are you trying to achieve? And why would you append "eOnce" to a string?

FanOfHumor

I have a function that inputs chosen settings into GLOB.Animate.I want the strings text either eRepeat or eOnce to be placed into GLOB.Animate where its needed.How would eOnce and eRepeat be made available as a parameter for a function. I assume there is a better way than using string.

Snarky

#8
Quote from: Pajama Sam on Tue 26/04/2022 07:02:09
I want the strings text either eRepeat or eOnce to be placed into GLOB.Animate where its needed

I don't think that's what you want. I think you want the values eOnce or eRepeat to be passed to the .Animate() method.

eOnce and eRepeat are values of the enum RepeatStyle, so you can just declare a parameter of the RepeatStyle type, just like the .Animate() method does.

The difference between the String "eOnce" and the value eOnce is a fundamental coding concept that is important to learn and understand. It's just like the difference between the String "true" and the boolean value true. The String "true" is just a sequence of four characters: [t,r,u,e]. AGS just stores it, it doesn't understand what it means. You can't write something like if(gWindow.Visible == "true"), because now you're comparing a boolean .Visible with a String "true," and that's like asking "which is bigger, the number 5 or a post-it note?" It doesn't make sense. It doesn't matter what's written on the post-it note: it might be "Hello" or "4"; it's still not comparable. (There are ways to read the text of the String/post-it note and convert it to a boolean or number, but then you would have to code that.)

The value true on the other hand is recognized when you compile the code, and converted into the computer's internal representation of the concept of truth (which is actually just a number, usually either 1 or -1). This allows it to be used in logical expressions, for example if(gWindow.Visible == true). When it is compiled, the actual words you've typed in the code are discarded, so that the internal representation of if(gWindow.Visible == true) doesn't contain the string "true".

Khris

Exactly, here's example code:

Code: ags
// top of global script
RepeatStyle GLOB_Repeat; // type RepeatStyle (int would also work) enables the correct auto-complete options

// inside some function
  GLOB_Repeat = eOnce; // no quotes, no strings are involved at any point

// elsewhere:
  player.Animate(..., GLOB_Repeat);

FanOfHumor

Thanks khris and snarky.

FanOfHumor

#11
How would I place the parameter globrepeatstyle in this function?

function nbobj(Object* GLOBALOBJ, int xpos, int ypos, int objview,int loop,int frame, int delay,globrepeatstyle)

EDIT:
Nevermind. I figured it out.

FanOfHumor

#12
I have this script here that seems to totally ignore the else statement.I'm trying to get the character to only be visible while speaking.So what's the problem with this?
Code: ags

  if(cfattymouth.Speaking)
  {
    cfattymouth.Transparency=0;
  }  
  else
  {
    cfattymouth.Transparency=100;
  }  

By the way.This is in repeatedly execute.

Crimson Wizard

Quote from: Pajama Sam on Tue 10/05/2022 14:14:06
I have this script here that seems to totally ignore the else statement.I'm trying to get the character to only be visible while speaking.So what's the problem with this?
Code: ags

  if(cfattymouth.Speaking)
  {
    cfattymouth.Transparency=0;
  }  
  else
  {
    cfattymouth.Transparency=100;
  }  

By the way.This is in repeatedly execute.

"repeatedly_execute" is not called during blocking actions, including blocking speech. Try placing this in "repeatedly_execute_always" instead.

More info on this: https://adventuregamestudio.github.io/ags-manual/RepExec.html

FanOfHumor

Thanks.I'll do that.Now for the sake of clarity.Since a room's script does not have repeatedly execute always it would not be able to do this script.Right?

Khris

You can do it in room scripts;  repeatedly_execute_always  is one of a few functions you can just add and they get called automatically, without the usual event linkage (the others being on_key_press and on_mouse_click).

FanOfHumor

#16
Is there a plausible way to do costumes in AGS that are like extra layers/limbs?

Crimson Wizard

#17
Quote from: Pajama Sam on Wed 11/05/2022 17:10:40
Is there a plausible way to do costumes in AGS that are like extra layers/limbs?

Similar questions have been asked couple of times only recently, here are related discussions:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=59912.0
https://www.adventuregamestudio.co.uk/forums/index.php?topic=59954.0

PS. I feel like we would benefit from a good tutorial and maybe an article in the manual on this topic.

FanOfHumor

Does drawing dynamic sprites have a baseline or z-order?

Crimson Wizard

Quote from: Pajama Sam on Wed 11/05/2022 18:50:37
Does drawing dynamic sprites have a baseline or z-order?

Dynamic sprites are just raw graphic, they dont have any baseline or position on their own. But they may be drawn on or assigned to an object, and object has a baseline or z-order.

SMF spam blocked by CleanTalk