flash as Q
- Started
- Last post
- 41 Responses
- st33d0
The invisibility bit is easy. Just say,
if x + width past the line or
y + height past the line then
_visible = false;The shoving up to meet the stuff bit is quite hard. I've been trying to do that for a Diablo clone for generating a dungeon.
I'm afraid you'll have to do some really annoying math for that.
- stewart0
okay...
why o why can't i get any further than this:
http://www.kulsdom.com/client/se…have a look at the .fla here:
http://www.kulsdom.com/client/se…
- mimeartist0
should do a dry run on paper... realy helps to get the idea of things and how they work... you'll end up wrapping yourself i code otherwise
- st33d0
I think it might look nicer working from top left.
http://pastebin.coconut.se/?id=4…
It would be easier to read, and the script I've done works from the biggest height downwards, so that could be changed to size or width or something (I've put an array sort function in there).
A group hug is always going to leave ugly gaps. I don't think that's going to help the rest of your design.
- stewart0
"should do a dry run on paper... realy helps to get the idea of things and how they work...
mimeartist
(Apr 11 07, 11:37)"haha!
believe it or not, but i've cut 20 different sized blocks from a paper and laying them donw on the floor one by one again and again before going back to the actionscript panel.i'm a llittle further now. i think i'll upload it tomorrow.
st33d, sorry, i can't ever READ your script. you must be brilliant.
- stewart0
let's give it a bump. maybe there's someone who can help me a little with this.
- enjine0
no, the recursive function is definitely the only way to go, if you're not griding out the blocks in a predictable order.
google "jared tarbell box fitting". he's got a great example of how to do it.
or use hitTest to move the boxes before displaying them (i.e. use a for loop instead of a time-based interval):
- st33d0
st33d, sorry, i can't ever READ your script. you must be brilliant.
stewart
(Apr 11 07, 11:46)That would be the case if my code was readable.
- mimeartist0
what you want to do is not think about centering them to begin with, as that will send you to a funny farm... treat each horizontal line of images seperately, and think of it like text wrapping, depending on how much the x axis is after adding one you then decide if you're going to wrap them or not... when you do adjust the y axis do it by the biggest from the previous line... then with the ones from the previous line work out how much space they take up... eg... if they take up 700 pixels on a 800 screen... then you simply add a buffer of 50 pixels to each of them, and they'll magically centre... with this you can then have as many rows as you like....
- mimeartist0
also... with the previous line... do the buffer to the y axis also... so use the value of the biggest one, and add a buffer to the smaller ones in the y direction...
did something similar for www.cosstores.com but with expanding boxes too... bit of a headf*** to be honest!
- stewart0
in my opinion at this moment it's already brilliant if flashplayer can read it.
i suck at translating my ideas into actionscript code.
should i quit making websites now?
- st33d0
Breaks my computer when I change the library.
- acescence0
i don't think he wanted the y position to be the same for every box on a line though
- mimeartist0
you seem to be getting there... but at times it looks like you could fit the box on the new line, on the previous line
- skt0
I quite like your solution over 2 rows keeping the top of the box's aligned.
- mimeartist0
read my 2nd bit... that would solve that
- st33d0
Damn I'm good:
http://pastebin.coconut.se/?id=4…
It works because the boxes are getting smaller.
If you have the movieclips in an array then you can use Flash's sort method to get them in size order by comparing _height.
- stewart0
aaaargh!
but i'm almost there, at least with a little help of you all...have a look at this:
i only want the blocks on the second line (and the third when there is one) shift up till they're 20px off the block above them.and i want the boxes that don't fit on the stage to be invisible.
here's the latest fla
http://www.kulsdom.com/client/se…thanks for your time again...
- qruise0
stage.width * stage.height = your real estate.
for each element {
blockspace += element.width * element.height;
if blockspace
- qruise0
fucknig moronic motherfucking newstoday...
if blockspace IS LESS THAN OR EQUAL TO your real estate {
make the block appear
}and as for the not overlapping part, im at work and dont have enough time to figure that out now.