View Full Version : Tonypa's Tile-based -> delete clip problem
Cybernoid
April 19th, 2005, 08:56 AM
I'm working on a tile-based game using Tonypa's tutorial as a basis.
I'm having trouble altering the tiles after the initial map has been built. I want to be able to change a tile into another on the fly.
_root.tiles.t_1_7.removeMovieClip();
removes the movieclip, but the array still holds the information of the clip. How can I change the array at that place?
Also, how can I use variables in a statement like the one above? I'm thinking of something like
_root.tiles.["t_"+Ytile+"_"+Xtile].removeMovieClip();
but that doesn't work.
Can anyone help?
SeiferTim
April 19th, 2005, 04:39 PM
I think you're set-up is a little off...
Take a look though my (simpler) tutorial http://seifertim.no-ip.com/rpgTut/page01.htm , and read through it thouroughly... I think you're on the right track, but need a little guidance. Without being able to see all your code (or at least the most pertinant part) I can't really say for certain where the trouble lies.
Sirisian
April 19th, 2005, 07:11 PM
u used a period! its _root.tile["STUFF"]
Cybernoid
April 20th, 2005, 02:58 AM
I think you're set-up is a little off...
Take a look though my (simpler) tutorial http://seifertim.no-ip.com/rpgTut/page01.htm , and read through it thouroughly... I think you're on the right track, but need a little guidance. Without being able to see all your code (or at least the most pertinant part) I can't really say for certain where the trouble lies.
So you're saying I should use a different "map" for the collectible items? I thought of that, but decided to try it this way. That's mainly because I'll be filling all the walkable spaces with items, so your way I'll have to do two similar maps.
I'll try the two-map-approach. Thanks.
Cybernoid
April 20th, 2005, 02:59 AM
u used a period! its _root.tile["STUFF"]
Umm, no. I need to point to
_root.tiles.t_1_7.removeMovieClip();
or similar, so there needs to be a period there.
foodpk
April 20th, 2005, 04:06 AM
No, _root.title.something is the same as _root.title["something"], you use array syntax since it kind of is an array (a movieclip containing several movieclips).
So it's _root.tiles["t_"+Ytile+"_"+Xtile].removeMovieClip();
Cybernoid
April 20th, 2005, 04:46 AM
No, _root.title.something is the same as _root.title["something"], you use array syntax since it kind of is an array (a movieclip containing several movieclips).
So it's _root.tiles["t_"+Ytile+"_"+Xtile].removeMovieClip();
Ok, thanks. I get it now.
So, now I can remove the movie clips, but the game still thinks the items are there, and adds score accordingly.
How could I delete the items once they're collected?
Cybernoid
April 20th, 2005, 05:58 AM
Ok, I solved the problem by using 1 map and an array for all the "eaten" items. I use my code to delete the items when the hero is on them and then store the X and Y into an array. When I come to an "item"-tile, I test wheather or not the hero has "eaten" it yet. If not, it eats it, if it has been eaten, I do nothing.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.