{lang: 'de'}
Flashhilfe.de - Flash Community

Punktestand aus Flash an PHP übergeben [Flash 9]

 


AntwortenRegistrieren Seite1  

Krebbin#1
Benutzerbild von Krebbin
Beiträge: 64
Registriert: Nov 2006

21.01.2010, 11:21

Hallo zusammen,

ich möchte gerne aus einem Flashgame (Ballhochalten) die größte Anzahl der geschafften Ballkontakte (highScore) übergeben und auslesen. Der Spieler hat jeweils 3 Leben. Wenn alle Leben aufgebraucht sind spring er in Frame 2, wo die Variable übergeben wird.

Mein Game-Script sieht so aus:

Bei Ballkontakt wird hochgezählt
ActionScript:
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var score:Number = 0;
var highScore:Number = 0;
var speedy:Number = 2;
var speedx:Number = 6;
var accely:Number = 1.6;
var radiusBall:Number = 10;
var life:Number: = 3

//startGame
startBtn.onRelease = function() {
   startGame();
      _root.ivwTrack("games");
   this._visible = false;
};
//
function startGame() {
   ball.onEnterFrame = function() {
      //vars
      speedy = speedy+accely;
      balllLocy = this._y+speedy;
      ballLocx = this._x+speedx;
      this._rotation += speedx;
      //check the vertical pos
      verticalCheck(this);
      //check the horziontal pos
      horizontalCheck(this);
      //update score
      scoreDisplay.text = score;
   };
}

//vertical check
function verticalCheck(target:MovieClip) {
   //if you hit the bottom
   if (balllLocy>(400-radiusBall)) {
      target._y = 400-radiusBall;
      speedy = -speedy*0.8;
      if(score > highScore){
         highScore = score;
         highScoreDisplay.text = highScore;
      }
      score = 0;
      life = -1;
      
      //if you hit the top
   } else if (balllLocy<0+radiusBall) {
      target._y = 0+radiusBall;
      speedy = -speedy*0.8;
      //else
      } else if (life = 0) {
gotoAndPlay (2);
   
      //else
   } else {
      target._y = target._y+speedy;
   }
}

//horizontal check
function horizontalCheck(target:MovieClip) {
   //if you hit the right
   if (ballLocx>(735-radiusBall)) {
      target._x = 735-radiusBall;
      speedx = -speedx*0.8;
      //if you hit the left
   } else if (ballLocx<0+radiusBall) {
      target._x = 0+radiusBall;
      speedx = -speedx*0.8;
      //else
   } else {
      target._x = target._x+speedx;
      speedx = speedx*0.97;
   }
}
//ball onPress
ball.onPress = function() {
   _root.ivwTrack("games");
   speedy = -20;
   speedx = -this._xmouse;
   score++;
};


In Frame 2 liegt nun folgendes Script:
ActionScript:
1
2
3
stop();
var punkte:Number = highScore;
getURL ("teams.php", "_self","POST");


In der teams.php lese ich die Variable aus
PHP:
1
2
3
4
5
<?
$howmuch 
$_POST["punkte"];
echo 
$howmuch;
?>


Müsste doch funktionieren oder?!
Ich konnte es leider noch nicht testen, da ich noch auf Zugangsdaten vom PHP-Server warte... aber ich wollte das Script schonmal fertig stellen.

Jedenfalls weiß ich nicht, ob es so funzt. Und wenn ja, dann habe ich das Problem, dass ich nicht weiß, wie ich das für mehrere "Teams" anlegen muss.
Ich habe nur ein Flash-File, möchte aber mehrere Teams das Spiel spielen lassen und am Ende eine Liste ausgeben, wo jedes Team seine Punktzahl sieht.

Ich müsste also die erzielten Punkte in einer Textdatei zwischenspeichern...oder?

Um noch etwas Verwirrung zu stiften muss ich kurz mal meine Datei-Struktur auf dem Server erläutern:

Soccerteam11.swf
Soccerteam22.swf
Soccerteam33.swf
usw...
Im Hauptverzeichnis "Soccer" liegt meine teams.php. In den Unterverzeichnissen liegt eine SWF für jedes Team und ich denke hier müsste noch jeweils eine z.B. counter.txt liegen, wo ich den jeweiligen Higscore abspeichere.

am Ende möchte ich halt eine Liste ausgeben, wo Man jedes Team und dessen Highscore sehen kann.

Ich weiß halt nur nicht, wie genau ich das anstellen muss.
Irgendwie sowas:

PHP:
1
2
3
4
5
<?
$team1 
= ("counter.txt");
$hits file($team1);
?>

und
PHP:
1
2
3
4
5
<?
$thisFileContent 
file("team1/counter.txt"); 
echo 
$thisFileContent[0];
?>


Ich bin nicht so ein Crack in PHP und weiß es deshalb nicht.

Es wäre super, wenn sich jemand meinem Problem annehmen könnte... ich weiß nicht so recht weiter :(

Besten Dank schonmal!
Schlagwörter: PHP, Punkte, Variablen
oceano#2
Benutzerbild von oceano
Beiträge: 10
Registriert: Jun 2005

22.01.2010, 14:42

hier: http://www.gym1.at/informatik/arge/13032003/flash/flash-php.pdf
Geändert von oceano am 22.01.10 um 18:07 Uhr
f0rml3ss#3
Benutzerbild von f0rml3ss
Beiträge: 447
Registriert: Mar 2008

22.01.2010, 17:23