Store a sound in a variable

Started by Rolando, Thu 20/06/2013 14:30:36

Previous topic - Next topic

Rolando

Hello everyone!, this is my first post so i apologize if this was asked before (wich i guess it was). Im finishing my first game demo and im working on sounds. I need to store a sound in a variable for playing it later but i cant find how to do this.

I need something like..

SoundTypeVar s1;
s1 = soundstored;
s1.play();

Thank you very much.

Phemar

Code: ags
AudioClip * sound = aSound1;
AudioChannel * ac = sound.Play ();

Rolando

Thank you very much Phemar, it works great. Just one question: what is the '*' before the variable name for????

Crimson Wizard

#3
Quote from: Rolando on Thu 20/06/2013 15:23:41
Thank you very much Phemar, it works great. Just one question: what is the '*' before the variable name for????

That's pointer.
Related manual article, strongly recommended for reading:
http://www.adventuregamestudio.co.uk/wiki/Pointers_in_AGS

Rolando

Thanks a lot Crimson! I never got into pointers, i definitly have to read that!

Crimson Wizard

Pointer is like an arrow sign on the road with city name on it. It points to something (like a city), but it is not a city itself.

You can change same pointer to point to different objects whenever you want. But when the program uses the pointer it does not care what object exactly it points to, it just takes whatever is there. This allows to run same commands with different objects.

SMF spam blocked by CleanTalk