NEU: Alle Visual Codes als Code Snippets für Flash CS5:
jetzt hier downloaden .
Hilfsflugzeug
Code Actionscript 2.0
Frame-Aktion
onMouseDown = function() {
package.speedy = 5.0;
package._y = plane._y;
package._visible = true;
}
Instanz-Aktion package
onClipEvent(load) {
speedy=0;
this._y= _parent.plane._y;
this._visible = false;
}
on (press) {
speedy = 5.0;
this._y = _parent.plane._y;
this._visible = true;
}
onClipEvent(enterFrame) {
// care-package moves with plane
this._x = _parent.plane._x;
// falling movement of care-package
this._y = this._y + speedy;
// reset
if (this._y > 410) {
trace("miss");
this._y=_parent.plane._y;
this._visible = false;
speedy = 0;
}
}
Instanz-Aktion plane
onClipEvent (load) {
speedx=3;
}
onClipEvent (enterFrame) {
// movement of plane
this._x = this._x+speedx;
// if planes leaves stage, restart at left edge
if (this._x > 440) {
this._x = -40;
}
}
Instanz-Aktion receiver
onClipEvent (enterFrame) {
// if care package was caught
if (this.hitTest (_parent.package)) {
trace ("thank you!");
this._alpha = 40;
// hide package
_parent.package._visible = false;
_parent.package._y = _parent.plane._y;
_parent.package.speedy = 0;
} else {
this._alpha = 100;
}
}
Code Actionscript 3.0
addEventListener(Event.ENTER_FRAME, enterFrame); stage.addEventListener(MouseEvent.MOUSE_DOWN, press); var speedx=3; var speedy=0; package1.y= plane.y; package1.visible = false; function press(e:MouseEvent){ speedy = 5; package1.y= plane.y; package1.visible = true; } function enterFrame(event:Event) { // movement of plane plane.x = plane.x+speedx; // if planes leaves stage, restart at left edge if (plane.x > 440) { plane.x = -40; } // care-package moves with plane package1.x = plane.x; // falling movement of care-package package1.y = package1.y + speedy; // reset if (package1.y > 410) { trace("miss"); package1.y= plane.y; package1.visible = false; speedy = 0; } // if care package was caught if (receiver.hitTestObject (package1)) { trace ("thank you!"); receiver.alpha = 0.4; // hide package package1.visible = false; package1.y = plane.y; package1.speedy = 0; } else { receiver.alpha = 1; } }
Infos
Ein Flugzeug hat die Aufgabe, Hilfsgüter zielgenau abzuwerfen. Dieses Spiel baut auf dem Button Fallenlassen, auf der Bewegung Abprallen, und auf der Bewegung Kollision auf.
verwandt mit: Abprallen, Kollision, Fallen lassen
Download
Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File