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

Brauche hilfe bei erstellung von items für ein flashGame [Flash 10]

 


AntwortenRegistrieren Seite1  

Deathkiller#1
Benutzerbild von Deathkiller
Beiträge: 22
Registriert: Jul 2010

01.07.2010, 10:52

Game v0.6 alpha.rar (133.46 KB)


Guten tag alle zusammen
Ich hab hier ein übles problem an dem ich schon seit tagen sitze und nicht weiterkomme.
Und zwar möchte ich ein Inventar für ein spiel erstellen.
soweit sogut...
habe als ausgangsskript das "game_invertory_v2" von http://www.freeactionscript.com
genommen und an mein game angepasst. funtz auch alles super solange ich alles im _root lasse
da mein inventar aber rausscrollen soll sobald ich mit der maus an eine bestimmte possition gehe habe ich einige mc´s gebraucht.
pfad ist jetzt "_root.Inventarcontainer.Inventar"
dort habe ich auch das skript reinkopiert und es funktioniert ebenfalls noch super ... ABER ... wenn ich das skript nicht im _root habe und 2 items erstelle dann verschwindet das erste wieder Oo
lasse ich das skript im _root kann ich unendlich viele erstellen .
hoffe mir kann jemand weiterhelfen ich verzweifele langsam und hab keine ahnung warum das net geht

//Edit: ich könnte das skript auch theoretisch im _root lassen, aber dann gehen meine itemslots die per array angesteruert werden und im "_root.Inventarcontainer.Inventar" liegen nichtmehr.Vll hat ja jemand eher ne lösung dafür.

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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
hier der code:

var slots_array:Array = new Array(slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24, slot25, slot26, slot27, slot28, slot29, slot30, slot31, slot32);
var items_array:Array;
var uniqueItemId:Number = 0;

//start dragging
function dragItem(_item:Object):Void {
     //save position before dragging
   _item.nowX = _item._x;
     _item.nowY = _item._y;
 
     //drag
   _item.startDrag(true);
     _item.onMouseMove = updateDrag;
}
//stop dragging
function dropItem(_item:Object):Void {
     //stop dragging
   _item.stopDrag();
 
     //delete mouse event
   delete _item.onMouseMove;
 
     //run loop on slots array
   for (i=0; i<slots_array.length; i++) {
        //set temp slot var
      currentSlot = eval(slots_array[i]);
        //---------------------------------------------------------------Check Item-----------------------------------

        //check slot hittest and slot itemID; if item is over slot and slot is empty, drop
      if (_item.typeID == "Weapon") {
           if ((eval(_item._droptarget) == currentSlot) && (currentSlot.itemID == "empty" || currentSlot.itemID == "Weapon")) {
              //place item in slot
            _item._x = currentSlot._x;
              _item._y = currentSlot._y;
 
              //update current slot itemID
            currentSlot.itemID = this;
 
              //update previous slot itemID
            temp = eval(_item.slotID);
              if (_item.slotID == "slot0") {
                 temp.itemID = "Weapon";
              } else {
 
                 temp.itemID = "empty";
              }
 
              //update current item slotID
            _item.slotID = currentSlot.myName;
 
              //item moved, end loop
            return;
           } else {
              //return item to previous position if: item is NOT over slot or slot is NOT empty
            _item._x = _item.nowX;
              _item._y = _item.nowY;
           }
        } else {
           if (_item.typeID == "Armor") {
              if ((eval(_item._droptarget) == currentSlot) && (currentSlot.itemID == "empty" || currentSlot.itemID == "Armor")) {
                 //place item in slot
               _item._x = currentSlot._x;
                 _item._y = currentSlot._y;
 
                 //update current slot itemID
               currentSlot.itemID = this;
 
                 //update previous slot itemID
               temp = eval(_item.slotID);
                 if (_item.slotID == "slot1") {
                    temp.itemID = "Armor";
                 } else {
 
                    temp.itemID = "empty";
                 }
 
 
                 //update current item slotID
               _item.slotID = currentSlot.myName;
 
                 //item moved, end loop
               return;
              } else {
                 //return item to previous position if: item is NOT over slot or slot is NOT empty
               _item._x = _item.nowX;
                 _item._y = _item.nowY;
              }
           } else {
              if (_item.typeID == "Extra") {
                 if ((eval(_item._droptarget) == currentSlot) && (currentSlot.itemID == "empty" || currentSlot.itemID == "Extra")) {
                    //place item in slot
                  _item._x = currentSlot._x;
                    _item._y = currentSlot._y;
 
                    //update current slot itemID
                  currentSlot.itemID = this;
 
                    //update previous slot itemID
                  temp = eval(_item.slotID);
                    if (_item.slotID == "slot2") {
                       temp.itemID = "Extra";
                    } else {
 
                       temp.itemID = "empty";
                    }
 
                    //update current item slotID
                  _item.slotID = currentSlot.myName;
 
                    //item moved, end loop
                  return;
                 } else {
                    //return item to previous position if: item is NOT over slot or slot is NOT empty
                  _item._x = _item.nowX;
                    _item._y = _item.nowY;
                 }
 
              } else {
 
                 if ((eval(_item._droptarget) == currentSlot) && (currentSlot.itemID == "empty")) {
                    //place item in slot
                  _item._x = currentSlot._x;
                    _item._y = currentSlot._y;
 
                    //update current slot itemID
                  currentSlot.itemID = this;
 
                    //update previous slot itemID
                  temp = eval(_item.slotID);
                    temp.itemID = "empty";
 
                    //update current item slotID
                  _item.slotID = currentSlot.myName;
 
                    //item moved, end loop
                  return;
                 } else {
                    //return item to previous position if: item is NOT over slot or slot is NOT empty
                  _item._x = _item.nowX;
                    _item._y = _item.nowY;
                 }
              }
           }
        }
     }
}

/*
* updateAfterEven re-renders the screen
*/

function updateDrag():Void {
     updateAfterEvent();
}

/*
* Create Slots
*/


var _currentSlot = slots_array[0];
_currentSlot.itemID = "Weapon";
_currentSlot.num = 0;
_currentSlot.myName = "slot"+0;

var _currentSlot = slots_array[1];
_currentSlot.itemID = "Armor";
_currentSlot.num = 1;
_currentSlot.myName = "slot"+1;

var _currentSlot = slots_array[2];
_currentSlot.itemID = "Extra";
_currentSlot.num = 2;
_currentSlot.myName = "slot"+2;

for (i=3; i<slots_array.length; i++) {
     var _currentSlot = slots_array[i];
     _currentSlot.itemID = "empty";
     _currentSlot.num = i;
     _currentSlot.myName = "slot"+i;
}


//Create Item

function createInventoryItem() {
     //attach item to stage
   var _item = attachMovie("item", "item"+uniqueItemId, _root.getNextHighestDepth());
 
     //set item position
   _item._x = -20;
     _item._y = 98;
 
     //--------------------------------------set item settings-------------------------------------------

     _item.myName = "item"+uniqueItemId;
     _item.slotID = "empty";
 
     //---------------------------------------Zufallsgenerrator
   itemtype = random(1)+1;
     if (itemtype == 1) {
        _item.gotoAndStop(1);
        _item.typeID = "Weapon";
        _item.extradmg = "5";
     }
 
     if (itemtype == 2) {
        _item.gotoAndStop(2);
        _item.typeID = "Armor";
     }
 
     if (itemtype == 3) {
        _item.gotoAndStop(3);
        _item.typeID = "Extra";
     }
     //----------------------onenterframe funktion----------------------------- 
   _item.onEnterFrame = function() {
        if (_item.typeID == "Weapon") {
           _root.extradmg = +(_item.extradmg);
        }
     };
     //----------------------onenterframe funktion ENDE ---------------------------
   //make item a button
   _item.onPress = function() {
        dragItem(this);
     };
     _item.onRelease = _item.onReleaseOutside=function () {
        dropItem(this);
     };
     //add item to array
   items_array.push(_item);
 
     //update unique Item Id
   uniqueItemId++;
  trace (uniqueItemId++)
}

_root.qwert.onRelease = function(){
  createInventoryItem();
}

Schlagwörter: game, Hilfe, inventar, item
Geändert von Deathkiller am 01.07.10 um 12:58 Uhr
Deathkiller#2
Benutzerbild von Deathkiller
Beiträge: 22
Registriert: Jul 2010

Themenautor/in

01.07.2010, 11:42

sry sehe grad das ist extrem unübersichtlich ... ich wollte aber auch nichts weglassen weil ich keine ahnung habe woran das liegen könnte .. denke mir aber hier irgendwo liegt der fehler

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
function createInventoryItem() {
       //attach item to stage
   var _item = attachMovie("item", "item"+uniqueItemId, _root.getNextHighestDepth());
 
       //set item position
   _item._x = -20;
       _item._y = 98;
 
       //--------------------------------------set item settings-------------------------------------------

       _item.myName = "item"+uniqueItemId;
       _item.slotID = "empty";
 
     
     //make item a button
   _item.onPress = function() {
          dragItem(this);
       };
       _item.onRelease = _item.onReleaseOutside=function () {
          dropItem(this);
       };
       //add item to array
   items_array.push(_item);
 
       //update unique Item Id
   uniqueItemId++;
    trace (uniqueItemId++)
}

_root.qwert.onRelease = function(){
    createInventoryItem();
}

Deathkiller#3
Benutzerbild von Deathkiller
Beiträge: 22
Registriert: Jul 2010

Themenautor/in

01.07.2010, 18:26

habe gerade festgestellt das

var items_array:Array

undefined ist wenn ich es antracer  :/

könnte das der grund sein wieso die items wieder gelöscht werden?


//EDIT: nein daran kanns eingendlich nicht liegen... ist im _root genauso aber dort funktionierts
verstehe das nicht ... wenn ich die items antracer hat auch jedes neu erstellte seinen eigenen namen
_level0.Inventarcontainer.Inventarfenster.item0
_level0.Inventarcontainer.Inventarfenster.item1
_level0.Inventarcontainer.Inventarfenster.item2
_level0.Inventarcontainer.Inventarfenster.item3
und im _root
_level0.item0
_level0.item1
_level0.item2
_level0.item3

nur das im _root die items bleiben und nichtmehr verschwinden
Geändert von Deathkiller am 01.07.10 um 18:32 Uhr
Deathkiller#4
Benutzerbild von Deathkiller
Beiträge: 22
Registriert: Jul 2010

Themenautor/in

02.07.2010, 12:13

ES IST VOLLBRACHT !!!
nach 5 tagen suche habe ich jetzt den fehler gefunden
ActionScript:
1
2
3
function createInventoryItem() {
     //attach item to stage
   var _item = attachMovie("item", "item"+uniqueItemId, _root.Inventarcontainer.Inventar.getNextHighestDepth());

so muss das aussehen
ActionScript:
1
2
3
function createInventoryItem() {
     //attach item to stage
   var _item = attachMovie("item", "item"+uniqueItemId, _root.getNextHighestDepth());
so wars vorher ....


und den instanznamen von Inventarfenster musste ich auf Inventar ändern.
jetzt geht alles genauso wie es soll

mir konnte zwar niemand hier helfen aber vll hilft das hier jemand anderem  :)
Geändert von Deathkiller am 02.07.10 um 12:15 Uhr

AntwortenRegistrieren Seite1  

Schnellantwort

Du musst registriert sein, um diese Funktion nutzen zu können.

 
Ähnliche Beiträge zum Thema
Partner Webseiten: art-and-law.de  Mediengestalter.info   phpwelt.de   Scubacube.de  
Haftungsausschluss   Datenschutzerklärung   Impressum
© 1999-2024 Sebastian Wichmann - Flashhilfe.de