Play sound via a text object

4

Attached Files

The following files have been attached to this tutorial:

.capx

textobject2sound.capx

Download now 373.06 KB

Stats

1,365 visits, 1,749 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

.

.

Like you, I like to minimize code to the fewest lines as possible.

So here is a little trick I just discovered when I was given a game example by korbaach.

I hope this helps you too.

For this capx example, I use families,

But,

if you wanted to use a sprite strip and name each animation frame separately,

that would work too.

To try the game in a new tab,

right click on the link

just below this line

Click Here to run sample game

Here is what the layout looks like (below),

just CLICK on an image after running.

.

.

here is the code (below)

thats all the code you need.

Its a bit confusing, but

you are accessing the audio via the text file ( in this case named item.text)

.

.

Important:

You will need to change the name of the animation frame

on each of the images to the corresponding sound file.

These names need to be the same or this will not work.

(below)

Enjoy

.

.

Smile

Smile if you think this tutorial will be useful in your projects

because smiles are free,

and so is clicking on favourite. :-) (hehe)

.CAPX

textobject2sound.capx

Download now 373.06 KB
  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!