Solution: Stop being retarded.

21 posts

Flag Post
2:38 [MossyStump] So the issue I'm having, I have a bunch of tiles. When the tile is created, the bitmap data is passed to the tiles class, and then is being masked. If I don't mask, all of the tiles appear normally
2:38 [MossyStump] But if I apply my mask, only the first tile will appear
2:39 [MossyStump] Yes, the mask is being created for each tile
2:39 [Senekis93] Err... code?
2:39 [MossyStump]  codeDMossySt3463944 
2:40 [Senekis93] Wait... so you're passing the whole tilesheet and masking it so it only displays one tile?
2:41 [MossyStump] Sorry, no, I'm passing _just_ whats to be displayed on the tile to the class
2:41 [MossyStump] All of that works fine, but when I try to mask it, it breaks
2:41 [Senekis93] How does it break?
2:42 [MossyStump] http://www.fastswf.com/u1pO0C0
2:42 [MossyStump] Without mask
2:42 [MossyStump] With mask
2:42 [MossyStump] http://www.fastswf.com/WoxO6qw
2:44 [Senekis93] So... when you apply the mask, only the first tile shows up? 
2:44 [MossyStump] Yes
2:44 [MossyStump] The other tiles are there, they're just blank
2:45 [Senekis93] Hm. Let me read the docs. I haven't used masks that much.
2:46 [isexcats] hey question, im trying to limit my  character to the screen but when i try and  run the swf it only limitsit to the top of the screen, the code im using to limit is  codeDisexcat1597863  and the swf link  is http://www.fastswf.com/hIPwUXM
2:47 [MossyStump] Are you factoring in the length of the paddle in that
2:47 [Senekis93] ^
2:47 [isexcats] yeah
2:47 [Senekis93] cache the following data: bottomlimit-paddle.height
2:48 [MossyStump] I don't want to go to work... I want to work on my GitD entry
2:48 [isexcats] im sorry, i just started using flash like a day ago,how wouldi do that?
2:49 [Senekis93] Mossy: "A single mask object cannot be used to mask more than one calling display object. When the mask is assigned to a second display object, it is removed as the mask of the first object, and that object's mask property becomes null."
2:49 [Senekis93] Could that be the issue?
2:49 [MossyStump] I'm not sure, I'm creating a new instance of the mask each time I add the classs
2:49 [Senekis93] isexcats: do something like bottomLimit=stage.stageHeight-paddle.height;
2:50 [isexcats] alright i'll  try that
2:50 [MossyStump] That sounds about on-page though for what's happening
2:51 [MossyStump] I have an idea 
2:51 [MossyStump] Instead of using something I drew as a mask, I'll make a sprite within the class and use THAT
2:51 [MossyStump] it'll be a pain to change later, but it'll have to do if that's the issue
2:53 [isexcats] thanksSenekis93  i got it to work!
2:53 [Senekis93] np.
2:54 [isexcats] `oh god i've just  realized something tragic
2:54 [MossyStump]  codeDMossySt4358419 
2:54 [MossyStump] Does the exact same thing :/
2:54 [MossyStump] Grawr
2:54 [isexcats] this is the first time i've really coded something in a few months
2:55 [Senekis93] Hmm. I'll try to recreate the issue, Mossy.
2:55 [MossyStump] Thanks
2:55 [MossyStump] Crap, brb. I got so wrapped up in my GitD work I forgot to put my laundry in the drier for work
3:01 [Senekis93] Ok. Managed to recreate it.
3:01 [MossyStump] Every tile needs to be masked for this to work how I want, I can't just make one giant mask to cover everything....
3:01 [Senekis93] Now let's find a way to fix it.
3:02 [MossyStump] I think it's because of the TileGroup class, I have multiple instances of the class, so even though each tile is its own instance of Tilegroup, it's only allowing one mask use
3:05 [Senekis93] lol.
3:05 [Senekis93] Silly issue.
3:05 [Senekis93] The problem is the position of the mask.
3:05 [Senekis93] You have to set it to the same position of the tile.
3:05 [Senekis93] All masks are being placed at 0,0.
3:06 [Senekis93] Thus, only the tile at that position is being displayed.
3:06 [MossyStump] I don't understand... The image is being placed at 0,0 as well for each tile
3:07 [Senekis93] Yeah, it makes no sense.
3:07 [Senekis93] I guess the docs cover that, but I don't feel like looking for it.
3:07 [Senekis93] But it would seem like the mask is applied to the stage.
3:07 [Senekis93] Instead of the actual object.
3:08 [Senekis93] To fix it, simply pass the x and y values of the tile to the constructor.
3:08 [Senekis93] Then use those values to move the mask around.
3:08 [MossyStump] ALright
3:10 [isexcats] does anyone know how to make one movie clip follow another one 
3:10 [isexcats] i seriously can't figure it out
3:10 [MossyStump] And it works! That's just... That's bizarre 
3:12 [MossyStump] Thanks Senekis!
3:12 [Senekis93] np.
3:12 [Senekis93] isexcats: trig.
3:13 [isexcats] trig  that i do not know
3:13 [isexcats] brb going on a google hunt
3:14 [MossyStump] Oh...
3:14 [MossyStump] It's because of the added to stage event
3:14 [MossyStump] Isn't it?
3:15 [MossyStump] No actually, interesting
3:15 [Kewry left GDR]
3:15 [MossyStump] Ah well, I'll solve this mystery later when I get home, I have to get ready for work and eat something 
3:16 [Senekis93] Yeah, it's the whole 0,0 thing. 
3:16 [MossyStump] I just don't understand why it's related to its position on the stage 
3:16 [MossyStump] Uh oh....
3:17 [MossyStump] Unless I can find a way to fix this, it's going to really bite me in the ass later, It won't be a _big_ issue, but it will be a pain
3:17 [MossyStump] I'll figure it out though
3:17 [MossyStump] I'm going to be moving these tiles around, which means I'll have to actively move the mask _with_ the tiles unless I can figure out how to fix this
3:18 [Senekis93] Hmm.
3:18 [MossyStump] Bbs though
3:18 [MossyStump] Can't put off getting ready for work any more if I wa nt to eat
3:18 [Senekis93] Same. Shower time. I'll take a look at it when I get back. 
3:18 [Senekis93] I dislike mysteries. 
3:18 [Senekis93] brb
3:33 [ST3ALTH15 left GDR]
3:49 [Senekis93] I still have no idea.
3:49 [Senekis93] I mean, the mask is a child of the instance of TileGroup. 
3:50 [Senekis93] So it'd be only logical if the mask moved along with it.
3:50 [MossyStump] That's what tripped me up in the first place, was I was thinking just that... I just don't understand _why_ it's not like that though or how to make it like that
3:51 [isexcats left GDR]
3:54 [Senekis93] I'm still doing some research. 
3:54 [Senekis93] If all else fails, I'll make a thread on the forums.
3:55 [MossyStump] You don't have to do all this, I can find the answer on my own. You've already done enough to help me :)
3:56 [MossyStump] OH
3:56 [MossyStump] I know why!
3:56 [Senekis93] Why!?
3:56 [MossyStump] It solves my issue kinda, but not fully
3:56 [MossyStump] Look
3:56 [MossyStump]  codeDMossySt8100557 
3:57 [MossyStump] I was tracing the position of the tile, and sorry to get you all excited, this solves part of my issue but not the entire issue
3:57 [MossyStump] The tile is at 0,0 when I add the mask, and THEN I change the tiles position
3:57 [MossyStump] That explains why the mask wasn't working before, but still doesn't explain why it's acting relative to the stage
3:57 [MossyStump] So sorry to get you excited x3
3:58 [Senekis93] lol, yeah.
3:58 [Senekis93] You could override the x and y setters of the TileGroup class to update the mask position whenever the tile moves.
3:58 [Senekis93] Although the mask should automatically do that.
3:59 [Senekis93] I hate mysteries. MUST KNOW THE ANSWER. u.u
4:00 [MossyStump] That's what I'll end up doing if this doesn't get figured out, it's so weird... 
4:00 [MossyStump] The docs don't really say anything that would explain this
4:01 [Senekis93] Wait...
4:01 [Senekis93] omg
4:02 [Senekis93] We're stupid.
4:02 [MossyStump] ?1
4:02 [Senekis93] LMAO
4:02 [MossyStump] You figured it out?!
4:02 [Senekis93] We never added the mask to the display list.
4:02 [Senekis93] hahahaha
4:02 [Senekis93] jfc, what a silly mistake.
4:02 [MossyStump] Wait, what
4:02 [MossyStump] Wo
4:02 [MossyStump] w
4:03 [Senekis93] addChild(maskSprite)
4:03 [Senekis93] LOL
4:03 [MossyStump] I feel
4:03 [MossyStump] SO stupid
4:03 [Senekis93] Me too.
4:03 [MossyStump] Like, seriously, that was just horrible
4:03 [Senekis93] Hahaha. 
4:03 [Senekis93] I'm laughing for real.
4:04 [MossyStump] To UG
4:04 [MossyStump]  codeDMossySt8536524 
4:04 [Senekis93] Dude, I spent the whole shower time breaking my head over it.
4:04 [MossyStump] I did too, it was driving me crazy
4:04 [Senekis93] xD
4:05 [MossyStump] Well that was fun XD
4:05 [Senekis93] Indeed. Oh, god... I'm gonna cry. :')
4:05 [Senekis93] Well, at least we found like five different ways to solve it.
4:05 [MossyStump] Lmao
4:06 [MossyStump] I'm just glad it got figured out before I went to work
4:06 [Senekis93] While our brains seem to fail for basic tasks such as remembering to add stuff to the display list, they proved to be able to solve complex things. xD
4:06 [Senekis93] I'm glad I didn't make that thread.
4:07 [Senekis93] It would have been silly as shit.
4:07 [MossyStump] Don't worry, one day programming IDE's will be able to warn us about things like this
4:07 [Senekis93] Yeah. In the meantime we can continue wasting hours solving issues like this one. -_-'
 
Flag Post

2:45 [Senekis93] Hm. Let me read the docs. I haven’t used masks that much.
4:01 [Senekis93] Wait…

That’s a long time to read that bit of text. ;P

 
Flag Post

I do that all the time. :| Now, missing addChilds is the first thing I look for.

 
Flag Post
Originally posted by NineFiveThree:

2:45 [Senekis] Hm. Let me read the docs. I haven’t used masks that much.
4:01 [Senekis93] Wait…

That’s a long time to read that bit of text. ;P

We simply implied that the whole “adding the mask to the display list” part was done and did never consider it while looking for the cause. Hence the whole “it makes no sense / it’s a child of the other object / its position should automatically update when the parent moves / why on earth is it staying at 0,0?” deal. -_-'

 
Flag Post

I also forget to addChild() at a rather alarming rate, but I tend to remember within an hour and a half.

 
Flag Post
Originally posted by feartehstickman:

I also forget to addChild() at a rather alarming rate, but I tend to remember within an hour and a half.

In my defense, masks don’t need to be added to work, which is why I was thrown off. We got the masks to work by working around what the original problem was, hadn’t the mask worked at all we probably would have figured it out sooner XD

 
Flag Post

tl;dr

 
Flag Post

On a slightly related note (stretching the “tiles” link a bit), how would I do this properly?

var tileMap:Array = [[2,2,2,2,2,3,3,3,4,4,4,2,2,2,2,…]];
var bigBitmap:Bitmap;
var bigBitmapData:BitmapData = new BitmapData(24<<5,26<<5);
for(var j:int = 0;j<26;j++){
for(var i:int = 0;i<24;i++){
var tile:Sprite;
if(!tileMap[j][i])tile=new Tile0();
else if(tileMap[j][i]==1)tile=new Tile1();
var bitmapData:BitmapData = new BitmapData(32,32);
bitmapData.draw(tile);
bigBitmapData.copyPixels(bitmapData,new Rectangle(32,32),new Point(i<<5,j<<5));
}
}
bigBitmap = new Bitmap(bigBitmapData);
addChild(bitBitmap);
It’s only getting called once (generating the level). For some reason, having the the tiles as Sprites made it lag a fair bit.
I’ve never really used bitmaps/datas before so I just cobbled this together and was very surprised when it worked.

 
Flag Post

Look up ‘Blitting’ on the web. It’s a great technique that will earn you a lot of performance leeway.

 
Flag Post

If you go a few years back on the programming forums, you can find records of a 3-day debugging session of mine that ended up being a semicolon after an if statement.

if (/*whatever*/);
{
   //Y ALWAYS EXECUTE?
}
 
Flag Post
Originally posted by feartehstickman:

On a slightly related note (stretching the &#8220;tiles&#8221; link a bit), how would I do this properly?

var tileMap:Array = [[2,2,2,2,2,3,3,3,4,4,4,2,2,2,2,&#8230;]];
var bigBitmap:Bitmap;
var bigBitmapData:BitmapData = new BitmapData(24&lt;&lt;5,26&lt;&lt;5);
for(var j:int = 0;j&lt;26;j++){
for(var i:int = 0;i&lt;24;i++){
var tile:Sprite;
if(!tileMap[j][i])tile=new Tile0();
else if(tileMap[j][i]==1)tile=new Tile1();
var bitmapData:BitmapData = new BitmapData(32,32);
bitmapData.draw(tile);
bigBitmapData.copyPixels(bitmapData,new Rectangle(32,32),new Point(i&lt;&lt;5,j&lt;&lt;5));
}
}
bigBitmap = new Bitmap(bigBitmapData);
addChild(bitBitmap);
It&#8217;s only getting called once (generating the level). For some reason, having the the tiles as Sprites made it lag a fair bit.
I&#8217;ve never really used bitmaps/datas before so I just cobbled this together and was very surprised when it worked.
Originally posted by I_love_you_lots:

Look up &#8216;Blitting&#8217; on the web. It&#8217;s a great technique that will earn you a lot of performance leeway.

This is where I learned from
http://www.8bitrocket.com/2008/7/2/Tutorial-AS3-The-basics-of-tile-sheet-animation-or-blitting/

 
Flag Post
Originally posted by truefire:

If you go a few years back on the programming forums, you can find records of a 3-day debugging session of mine that ended up being a semicolon after an if statement.

if (/*whatever*/);
{
   //Y ALWAYS EXECUTE?
}

And that’s why I do it like this:

if(/*whatever*/) {
  //Y ALWAYS WORK CORRECTLY!
}

They cuddle up together, then stray semicolons are obvious.

 
Flag Post

Having a whole new line just for that { seems kinda silly anyways, it increases the number of lines which makes it harder to navigate.

 
Flag Post

I personally find the spaces make it easier to navigate.

 
Flag Post
Originally posted by Drakim:

Having a whole new line just for that { seems kinda silly anyways, it increases the number of lines which makes it harder to navigate.

Increasing the number of lines is good, because then you can brag about how “your program is bigger.” Size is good, right? Anyway to me, it seems easier to navigate code blocks when the { is on its own line. I also find it easier to spot any mismatched brackets when the opening and closing bracket pairs line up nicely with each other.

Besides, FD is nice and will warn you about semicolons after if statements.

 
Flag Post
Originally posted by Aesica:

Besides, FD is nice and will warn you about semicolons after if statements.

FD will also warn you about mismatched brackets. Also, you aren’t going to resolve this debate any time soon, so I suggest not bothering.

 
Flag Post

I prefer my code compact, so I’d never use a new line for such stuff. I actually skip the whole braces thing when I can get away with it.

This shouldn’t even be a debate, given that it’s just a personal choice and whatever others may think of the way you structure your code is irrelevant. Even in the case of a software company when some sort of structure is expected, you could simply code the way you like to and make some autoformatter to meet whatever stupid requirements the company imposes.

 
Flag Post
Originally posted by player_03:

Also, you aren&#8217;t going to resolve this debate any time soon, so I suggest not bothering.

Yeah, I know. In a sense, it’s like debating which political party or religious affiliation is right or wrong. All that really matters is that they follow what works for them because they like it.

Having said that: All hail the almighty Newlined Opening Bracket. For He has taken on a life of sacrifice and solitude so that we may be more easily forgiven our programming sins. In His name we pray, amen!

 
Flag Post

I’m a member of the compact coding side of this discussion, for the record. I don’t even bother with braces or a newline if it’s a one line statement.

My opinion is that code is always ‘long and thin’ anyway, and screens are short and wide, so why make that mismatch even worse by using short lines and wasting vertical space on unnecessary ones?

 
Flag Post

My reasons for putting braces around single line conditional statements are:

1) it makes it easier to see the scope (although the indenting will do that as well, though there have been several times that incorrectly-scoped conditional statements went unnoticed because of the coder’s habit of not bracing single-line conditionals — I’ve even done it myself once or twice a long time ago. As a matter of fact, I have a Java programming textbook that has an example code segment where they accidentally do this (it wasn’t for “beware of this” example purposes), with a single line after the conditional indented, but several lines after that that were supposed to be included)
2) if I need to add other things inside, the braces are already there

As for compactness, if your code segments are terse enough that they fit on the screen, bracing the odd single-line conditional shouldn’t have too much of a delitirious effect. If they don’t, then it shouldn’t make a difference anyway.

The reasons why I like the starting brace on its own line:

1) I can easily see that I’ve matched the braces (or, more correctly, I can easily see where I missed a brace: editor programmes have long had colouring and indenting to denote code blocks, but it can still be a bit of a headache finding the spot where a brace was accidentally left out or deleted. Looking at the jagged line ends is more difficult than looking at the considerably less jagged line beginnings)
2) it looks better from a slightly OCD viewpoint (yay for symmetry!)

 
Flag Post

In Mossy’s defense. I myself have difficulties understanding masks, or blitting for that matter. So I can see how challenging it can be to get it right.