How do I add an audio to an object

Get help using Construct 2

Post » Sat Mar 15, 2014 2:09 pm

ok thanks a lot
B
5
Posts: 35
Reputation: 331

Post » Sun Mar 16, 2014 2:48 pm

First view this to see what the results would be-https://dl.dropboxusercontent.com/u/128026415/SoundTest/index.html
Move with the arrow keys

**Note disregard the toggle button doesn't function***
WHAT IS HAPPENING?
What I did was setup a soundRange that follows the player where ever they go and each level triggers the sound for that object. Green for low level sound Yellow for Mid level sound and Red for full sound. (Which you can see in the top image below)

IMPLEMENTATION
Now for the soundLevels I set a instance variable called soundRange to tell what level to play the sound at. for the object 'Fire' it has two variable instance 'soundFile'-for the audio file that needs to be played and 'inRange'-which is triggered when they enter the Green Zone. When object exits it zeros it out and stops the tagged sound.

I did it this way cause I notice from your profile you don't have a license. So look at how my events is setup below and try to implement it yourself. Also I did test it on my android in Cocoonjs and it did work for me.

Image

But if you have more items for sound depending on range a license would be beneficial because you can use Families. Which is nice cause you can declare the instance variable in that and it would be transferred to whatever objects is in the family and you can set each object as you please.

With Families it would look like this::
Image

So any object in soundItems would be tested.

**UPDATE**Just pin each range to the playerSprite is better.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sun Mar 16, 2014 10:08 pm

Updated the events a little more. This uses 'Families' so I don't have to setup the same event for each object that has sound. Also make it that when a object triggers the sound to make it so that another object that may have the same file to make each object sound tag unique I used their UID in the naming of the sound.

You can see the changes here-http://bit.ly/1fOoXrp
Use the arrow keys to move the purple box.

::SCENE LAYOUT::
Image

::EVENT CHANGES::
Image

If you don't have a license for every object that you wanted to do something like this you would have to set up the event individually or use frames...but then code each soundfile for each frame. Which does become unreadable to an extent and make a higher possibility of errors.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Mon Mar 17, 2014 2:03 am

wow you're great man, I'll will have to take some time to look at this! ^^
btw, just wanna ask a different topic things, how to add ads into my game without going using eclipse or other advanced programming tools? And I've searched a lot in google about MoPub and AdMob, it requires me to add MoPub SDK into eclipse and bla bla bla all the coding, so I just wanna ask is there an easier way to set up ads into my mobile game? Best is it doesn't require money
B
5
Posts: 35
Reputation: 331

Post » Mon Mar 17, 2014 3:56 am

Can't answer that at the moment cause I haven't done it. but I am planning to package something soon and have been trying to see if I can integrate Amazon or Chartboost which would probably require me to go through eclipse to do.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Mon Mar 17, 2014 6:22 am

I think the only way is to get premium account in cocoonjs, as it automatically helps you add ads server into your game during compilation. I've requested for premium account, hopefully they will give me.
B
5
Posts: 35
Reputation: 331

Post » Wed Mar 19, 2014 12:39 am

Yes you need premium I will test it out. I just got approved.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Wed Mar 19, 2014 7:18 am

@phoenixNightly me too! I also got upgraded to premium, so now I have to register AdMob and put it in MoPub, first time doing all these things, need to read carefully.
B
5
Posts: 35
Reputation: 331

Post » Wed Mar 19, 2014 2:39 pm

hey i was wondering are you doing all the MoPub stuffs? Because I seems to have problem with the Banner Ad, which my game doesn't show up any banner ad, but fullscreen ad it can show up, once or twice only.
B
5
Posts: 35
Reputation: 331

Post » Wed Mar 19, 2014 4:13 pm

I added ChartBoost. Not Admob...yet. The only thing I see when I run my app in CocoonJS Launcher is that I messed up on the ad refresh. But it shows a Banner ad.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: gameba and 7 guests