PDA

View Full Version : need help with items!



theloger
February 8th, 2005, 10:14 AM
Im trying to make a game but i need some help with items. I cant get two items show up on the map,only one appears. If someone can help me fixing my code ill aprecciate:

function placeItems (map) {
_root.attachMovie("empty", "items", this.getNextHighestDepth());
var mapWdth = map[0].length;
var mapHght = map.length;
for (var i = 0; i < mapHght; i++) {
for (var j = 0; j < mapWdth; j++) {
switch (map[i][j]){

case 1:
_root.items.attachMovie("Guy","guy_mc", d++);
_root.items.guy_mc._x = (_root.tileWdth * j);
_root.items.guy_mc._y = (_root.tileHght * i);

case 2:
_root.items.attachMovie("Cash","cash_mc", d++);
_root.items.cash_mc._x = (_root.tileWdth * j);
_root.items.cash_mc._y = (_root.tileHght * i);

}
}
}
}
placeItems(itemMap1);

SeiferTim
February 8th, 2005, 10:18 AM
Hmm...
the only thing I can think of is the depth... but I'm not sure... what does your Map Matrix look like? And what's not showing up?

SeiferTim
February 8th, 2005, 10:19 AM
I might try changing this:

_root.items.attachMovie("Guy","guy_mc", d++);

To this:


_root.items.attachMovie("Guy","guy_mc", _
getNextHighestDepth());
and see if that helps. Change it for the other items, too.

shotmenot
February 8th, 2005, 10:22 AM
are u sure that you got all the names right, you might have to name of one of the items wrong, you might have it named different then it is in the script.

SeiferTim
February 8th, 2005, 10:24 AM
Ah
Jeez
I'm dumb :P
Hang on:


function placeItems (map) {
_root.attachMovie("empty", "items", this.getNextHighestDepth());
var mapWdth = map[0].length;
var mapHght = map.length;
for (var i = 0; i < mapHght; i++) {
for (var j = 0; j < mapWdth; j++) {
switch (map[i][j]){

case 1:
_root.items.attachMovie("Guy","guy_mc", d++);
_root.items.guy_mc._x = (_root.tileWdth * j);
_root.items.guy_mc._y = (_root.tileHght * i);

case 2:
var name = "cash_"+j+"_"+i;
_root.items.attachMovie("Cash",name, d++);
_root.items[name]._x = (_root.tileWdth * j);
_root.items[name]._y = (_root.tileHght * i);

}
}
}
}
placeItems(itemMap1);

You have to make each "cash_mc" have a unique identifier, ie, name. Otherwise, they're all called "cash_mc", and you just keep replacing them. Let me guess, only the last coin would show up, right?
Sorry 'bout that. I haven't gotten to that part in the tutorial, but I should add it soon, huh? ;)

theloger
February 8th, 2005, 11:50 AM
Well i tried what u said seifer, but its still only showing up the coin and not the guy, i believe im doing something wrong cuz when i do this:

case 1:
_root.items.attachMovie("Guy",name, d++);
_root.items.guy_mc._x = (_root.tileWdth * j);
_root.items.guy_mc._y = (_root.tileHght * i);

case 2:
var name = "cash_"+j+"_"+i;
_root.items.attachMovie("Cash",name, d++);
_root.items[name]._x = (_root.tileWdth * j);
_root.items[name]._y = (_root.tileHght * i);

Only the coin shows up, but when i change the places:

case 1:
var name = "cash_"+j+"_"+i;
_root.items.attachMovie("Cash",name, d++);
_root.items[name]._x = (_root.tileWdth * j);
_root.items[name]._y = (_root.tileHght * i);

case 2:
_root.items.attachMovie("Guy",name, d++);
_root.items.guy_mc._x = (_root.tileWdth * j);
_root.items.guy_mc._y = (_root.tileHght * i);

The guy appears but the coin doesnt. Can u explain me this? thx

shotmenot
February 8th, 2005, 11:54 AM
what are the names of the items (like all the names)

and are you sure you have all the scripting clean and edited like the }'s

theloger
February 8th, 2005, 12:05 PM
i only have two items, the guy, and the money. The MC of the guy is called "moving_mc" like is seifer's tutorial, the linkage of that mc is "Guy". The money MC is called "money_mc", the linkage is called "Cash" AND the mc inside of money_mc is called "cash_mc".

All the scripting is clean, there are no errors on it.

shotmenot
February 8th, 2005, 12:07 PM
you might want to try calling it (with the linkage thing) guy_mc

SeiferTim
February 8th, 2005, 01:00 PM
case 2:
_root.items.attachMovie("Guy",name, d++);
_root.items.guy_mc._x = (_root.tileWdth * j);
_root.items.guy_mc._y = (_root.tileHght * i);
There's your problem
There is only One guy, so you definiately don't want to use "name" for him.

case 2:
_root.items.attachMovie("Guy","guy_mc", d++);
_root.items.guy_mc._x = (_root.tileWdth * j);
_root.items.guy_mc._y = (_root.tileHght * i);

SeiferTim
February 8th, 2005, 01:01 PM
And try using
getNextHighestDepth() instead of
d++ I find it tends to work better, sometimes.

theloger
February 8th, 2005, 02:01 PM
It worked. Thx

SeiferTim
February 8th, 2005, 02:03 PM
What fixed it?

theloger
February 8th, 2005, 06:04 PM
the "getNextHighestDepth()" instead of "d++" fixed it. I used it on the guy case and d++ on the money case and it worked.

theloger
February 8th, 2005, 06:07 PM
Ill wait for the actualization of your RPG programming tutorial to learn more about this and making items interact each other on the map.

SeiferTim
February 9th, 2005, 09:16 AM
Well, I'm working on it :beam:
just for the record, this worked, right?
function placeItems (map) {
_root.attachMovie("empty", "items", this.getNextHighestDepth());
var mapWdth = map[0].length;
var mapHght = map.length;
for (var i = 0; i < mapHght; i++) {
for (var j = 0; j < mapWdth; j++) {
switch (map[i][j]){

case 1:
_root.items.attachMovie("Guy","guy_mc", getNextHighestDepth());
_root.items.guy_mc._x = (_root.tileWdth * j);
_root.items.guy_mc._y = (_root.tileHght * i);

case 2:
var name = "cash_"+j+"_"+i;
_root.items.attachMovie("Cash",name, getNextHighestDepth());
_root.items[name]._x = (_root.tileWdth * j);
_root.items[name]._y = (_root.tileHght * i);

}
}
}
}
placeItems(itemMap1);
By the way, if you've seen my section on Doors, you'll notice that I changed the way the character is placed a little bit. Yeah, yeah, I know... always changing stuff around on you :P

abraxas
February 9th, 2005, 02:21 PM
hmm, i got a problem with the "guy"

he doesnt shows up, because he is under the map!?!?
how do i make so he is over it? it worked before but now he is under, really weird.

SeiferTim
February 9th, 2005, 04:02 PM
Just make sure that you place the guy last.



MapMaker(map1);
placeItems(itemMap1);
placeGuy(6,4);

abraxas
February 9th, 2005, 05:01 PM
Just make sure that you place the guy last.



MapMaker(map1);
placeItems(itemMap1);
placeGuy(6,4);

hmm that dont seems to work :(
i made a new fla.. making like a bomberman game, and need help with a thing

the rocks that can be blown away with bombs, how to do these?
should i make like a map with tiles, that can be destroyed when a bomb is in 64 pix near? (i dont know how do to that either :()

abraxas

theloger
February 9th, 2005, 09:28 PM
well , sry about posting so late i didnt conect today.
I only used the "getnexthighestdepht()" on the guy and on the money i used d++, that way the money and the guy shows up. if i use "getnexthighestdepht()" on both only the money shows up.

theloger
February 9th, 2005, 09:30 PM
By the way, is possible to use DuplicateMovieClip on the coins to make appear more coins on the map?:ear: :hugegrin:

SeiferTim
February 9th, 2005, 10:04 PM
It's possible, I guess, but I don't think it would matter...

theloger
February 10th, 2005, 10:32 AM
Just an idea to make things simpler i guess...

SeiferTim
February 10th, 2005, 10:39 AM
Well, from what i understand, DuplicateMovieClip makes a copy of an MC which is already on the stage, whereas AttachMovie makes a copy of an MC which is in the Library, and places it on the Stage. The main reason Attach is better in this case is because you won't have to have a bunch of MCs on the stage (most likely off to the side somewhere, or otherwise hidden) to make copies from - and it can cut down on some confusion. When I get the time to work on it, my next section will be about placing items on the map for the player to grab... and I'll talk about items that can be picked up by walking over them, and also things like Chests which the user has to interact with, and once used, are always open.

abraxas
February 10th, 2005, 12:08 PM
I need help with the frames at the guy
I want it to change frame when turning 90 degrades so he doesnt only look rotated (for 0, 90, 180, 270)

And, how is it possible to make a button place a tile at the place the guy is standing on when testing the fla? What is the AS?

I asked how to do a bomb before, but i didnt got any answers :(

SeiferTim
February 10th, 2005, 03:07 PM
You'll want to take the player's current X,Y coordinates, and just place an object in the same place. Like, say you assign the key "B" to be your bomb, then when you do all your key-checks, say:
if (Key.isDown(key.B)) { // I don't know if that's right - probably not, but I'm not at home with Flash.
_root.bombCount++;
var name = "bombs" + _root.bombCount;
_root.itemmap.attachMovie("bomb",name, getnexthighestdepth());
_root.itemmap[name]._x = _parent._x;
_root.itemmap[name]._y =_parent._y;

}

Something close to that should work. Again, I'm not at home, so you will definialtely want to look up the correct commands, and things... but basically, that'd work.

abraxas
February 10th, 2005, 04:38 PM
ok this was a tricky one ;)
First; should i have this bomb code under place items?


Second; im working on 2 guy that i want moving around, how do i then get so each player can lay an own bomb if i put the code under place items (from your tutorial :))
And i need to make a bomb mc right?

i maybe got a problem with the second guy, because he dont show up right now. i will take a look before asking help on that :)

abraxas
February 11th, 2005, 12:50 PM
ok i really got some problems now :(
i have made my bomb mc, but it doesnt makes a bomb mc when precis down B (the selected key), i dont know if it under the tiles :(