[FLASH 8] Geluiden afspelen op actie

Pagina: 1
Acties:
  • 171 views sinds 30-01-2008

  • klomp
  • Registratie: September 2001
  • Laatst online: 22-11-2025
Ik ben bezig met een Pong spelletje, oorspronkelijk voor mijn opleiding, maar nu ik hem af heb volgens hoe het moest voor school, ben ik er voor de lol nog wat in verder gegaan.

Ik probeer nu flash zo ver te krijgen dat er een geluidje af word gespeeld zodra het balletje 1 van de rackets raakt. Maar ik kan nergens vinden welke code ik daarvoor moet gebruiken.

Ik neem aan een HitTest? Maar waarin? En hoe? Ik heb de codes voor het weerkaatsen en de snelheid van het balletje enzo, in het symbool (balletje) zelf gebouwd en die gaat als volgt:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
onClipEvent (enterFrame) {
if (this._y<65) {
    richtingY = -richtingY;}
if (this._y>280) {
    richtingY = -richtingY;}
if (this.hitTest(_root.racketLinks)) {
    richtingX = -richtingX;}
if (this.hitTest(_root.racketRechts)) {
    richtingX = -richtingX;}
if (this.hitTest(_root.gooba)) {
    richtingX = -richtingX;}
if (this.hitTest(_root.yoshi)) {
    richtingX = -richtingX;}
this._x += richtingX*snelheid;
this._Y += richtingY*snelheid;
if (this._x > 400) {
    _root.puntenA++;
        this._x = 40;
        this._y = Match.round(random(100)+50);}
if (this._x < 0) {
    _root.puntenB++;
        this._x = 360;
        this._y = Match.round(random(100)+50);}
if (_root.puntenA == 5 || _root.puntenB == 5) {
    _root.gotoAndStop(3);}
}


Hoe kan ik daar nu geluid in krijgen?

Eventueel kan het spelletje zelf gecheckt worden, maar de link post ik pas later omdat ik niet weet of zoiets onder spam ofzo valt :)

  • Splash
  • Registratie: September 2001
  • Laatst online: 11-04 17:23
Ervan uitgaand dat je geluidje in de library staat en is ge"export for actionscript" (rechtsklik erop)

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//maak een nieuw Sound object:
var geluid:Sound = new Sound();
//laad het geluidje uit de library hier in:
geluid.attachSound("geluidje");

onClipEvent (enterFrame) {
if (this._y<65) {
    richtingY = -richtingY;}
if (this._y>280) {
    richtingY = -richtingY;}
if (this.hitTest(_root.racketLinks)) {
    richtingX = -richtingX;
    //speel geluidje als balletje linker racket raakt:
    geluid.start();
}
if (this.hitTest(_root.racketRechts)) {
    richtingX = -richtingX;
    //speel geluidje als balletje rechter racket raakt:
    geluid.start();
}
if (this.hitTest(_root.gooba)) {
    richtingX = -richtingX;}
if (this.hitTest(_root.yoshi)) {
    richtingX = -richtingX;}
this._x += richtingX*snelheid;
this._Y += richtingY*snelheid;
if (this._x > 400) {
    _root.puntenA++;
        this._x = 40;
        this._y = Match.round(random(100)+50);}
if (this._x < 0) {
    _root.puntenB++;
        this._x = 360;
        this._y = Match.round(random(100)+50);}
if (_root.puntenA == 5 || _root.puntenB == 5) {
    _root.gotoAndStop(3);}
}


Overigens kun je dit soort dingen ook prima vinden door even in de help (f1) of op internet (google) te zoeken, dus doe dat voortaan eerst even.

  • klomp
  • Registratie: September 2001
  • Laatst online: 22-11-2025
Omfg weer zo een die meteen begint met blabla, ik zeg toch ik heb gezocht, engels is niet mijn sterkste kant dus vraag ik het hier. Ik wist niet welke zoektermen ik moest gebruiken dus ja :/ thanks all the same.

  • Guillome
  • Registratie: Januari 2001
  • Niet online

Guillome

test

Wat zeur je nou, hij geeft je de complete oplossing, en hij heeft wel gelijk. Een geluidje starten in flash is makkelijk te vinden.

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router


  • klomp
  • Registratie: September 2001
  • Laatst online: 22-11-2025
Lol nog zo één, stel kudde dieren ofzo.

Lees wat ik zeg dan snap je wat ik bedoel :/

  • ZjieB
  • Registratie: Juli 2002
  • Laatst online: 31-10-2025
Ik begrijp in ieder geval dat de dankbaarheid niet echt van je posts afdruipt. Iemand die behulpzaam is bedanken hoort iig (net als Engels) niet tot je sterke punten.

  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

Probeer dit maar te begrijpen:

With such an attitude, you're the weakest link. Goodbye :/

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.

Pagina: 1

Dit topic is gesloten.