Zurück   Flashforum > Flash > ActionScript > ActionScript 2

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 11-09-2009, 00:53   #1 (permalink)
Neuer User
 
Benutzerbild von option
 
Registriert seit: Aug 2006
Beiträge: 357
racing game - hintergrund bewegen

hi

ich hab ein schönes "racing-game" tutorial gefunden:
> Flash Games Tutorials / Open Source Flash Games on GameSheep.com
> download der .fla datei: http://www.gamesheep.com/free/flash-...art1_step4.zip

allerdings versteh ich nicht wie das auto mit der instanz "car1" überhaupt angesprochen wird!
ich würde gerne das spiel so ändern das der wagen in der mitte fixiert ist und sich stattdessen der hintergrund bewegen. (der effekt nennt sich glaube ich "top down scroller" o.ä.?)

kann mir jemand helfen das problem zu lösen?

hier mal ein ausschnitt aus dem AS:
ActionScript:
  1. if (_root["car"+who].code == "player") {
  2.         //we will constantly decrease speed by multiplying it with a number below 1
  3.         //trace(this);
  4.  
  5.         if (this["speed"+who]>0.3) {
  6.             this["speed"+who] *= _root.speedDecay;
  7.         } else {
  8.             this["speed"+who] = 0;
  9.         }
  10.         //---------------------------------------------------------------
  11.         //the car will react to certain keys
  12.         //accelerate
  13.         if (Key.isDown(Key.UP) && this["speed"+who]<_root.maxSpeed) {
  14.             //if the acceleration key is down, the engine sound volume is set to 100
  15.             this["speed"+who] += _root.acceleration;
  16.         }
  17.         //brake (reverse)     
  18.         if (Key.isDown(Key.DOWN)) {
  19.             this["speed"+who] -= _root.backSpeed;
  20.         }
  21.         //steer left       
  22.         if (Key.isDown(Key.LEFT) && Math.abs(this["speed"+who])>0.3) {
  23.             _root["car"+who]._rotation -= _root.rotationStep*(this["speed"+who]/_root.maxSpeed)/1.25
  24.             //_root["car"+who].drehen(-_root.rotationStep*(this["speed"+who]/_root.maxSpeed), 8);
  25.             //drehle = _root["car"+who]._rotation -= _root.rotationStep*(this["speed"+who]/_root.maxSpeed);
  26.             //_root["car"+who].drehen(drehle, 10);
  27.         }
  28.         //steer right       
  29.         if (Key.isDown(Key.RIGHT) && Math.abs(this["speed"+who])>0.3) {
  30.             _root["car"+who]._rotation += _root.rotationStep*(this["speed"+who]/_root.maxSpeed)/1.25
  31.         }
  32.         //--------------------------------------------------------------- 
  33.         this["rotation"+who] = _root["car"+who]._rotation;
  34.         //we calculate the two components of speed (X axis and Y axis)
  35.         this["speedx"+who] = Math.sin(this["rotation"+who]*(Math.PI/180))*this["speed"+who];
  36.         this["speedy"+who] = Math.cos(this["rotation"+who]*(Math.PI/180))*this["speed"+who]*-1;
  37.         //apply the components on the actual position of the car
  38.         _root["car"+who]._x += this["speedx"+who];
  39.         _root["car"+who]._y += this["speedy"+who];
  40.         //the collisions
  41.         //define the four collision points
  42.         _root["car"+who].pointLeft = {x:-20, y:0};
  43.         _root["car"+who].localToGlobal(_root["car"+who].pointLeft);
  44.         _root["car"+who].pointRight = {x:20, y:0};
  45.         _root["car"+who].localToGlobal(_root["car"+who].pointRight);
  46.         _root["car"+who].pointFront = {x:0, y:-25};
  47.         _root["car"+who].localToGlobal(_root["car"+who].pointFront);
  48.         _root["car"+who].pointBack = {x:0, y:25};
  49.         _root["car"+who].localToGlobal(_root["car"+who].pointBack);
  50.         //let's use some shorter variable names :)
  51.         this["lpx"+who] = _root["car"+who].pointLeft.x;
  52.         this["lpy"+who] = _root["car"+who].pointLeft.y;
  53.         this["rpx"+who] = _root["car"+who].pointRight.x;
  54.         this["rpy"+who] = _root["car"+who].pointRight.y;
  55.         this["fpx"+who] = _root["car"+who].pointFront.x;
  56.         this["fpy"+who] = _root["car"+who].pointFront.y;
  57.         this["bpx"+who] = _root["car"+who].pointBack.x;
  58.         this["bpy"+who] = _root["car"+who].pointBack.y;
  59.         //check for collisions
  60.         if (_root.terrain.hitTest(this["lpx"+who], this["lpy"+who], true)) {
  61.             _root["car"+who]._rotation += 5;
  62.             this["speed"+who] *= 0.85;
  63.         }
  64.         if (_root.terrain.hitTest(this["rpx"+who], this["rpy"+who], true)) {
  65.             _root["car"+who]._rotation -= 5;
  66.             this["speed"+who] *= 0.85;
  67.         }
  68.         if (_root.terrain.hitTest(this["fpx"+who], this["fpy"+who], true)) {
  69.             this["speed"+who] = -1;
  70.         }
  71.         if (_root.terrain.hitTest(this["bpx"+who], this["bpy"+who], true)) {
  72.             this["speed"+who] = 1;
  73.         }

Geändert von option (11-09-2009 um 00:54 Uhr)
option ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Hintergrund bewegen slaveZero Flash Einsteiger 2 12-10-2006 17:07
racing game - stecken kollision webholics.de ActionScript 2 4 27-07-2006 19:23
Nettes Racing Game in Pseudo 3D Optik Flashbob 3D 11 23-06-2006 16:59
racing game engine problem der_oki Flash 4 und Flash 5 4 02-03-2004 08:07
game hintergrund nur im aktiven feld anzeigen.. sina ActionScript 1 3 17-11-2002 11:13


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:34 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele