Setting Up the Visuals
At this stage we have an xml that is loaded in through our rss feed that was generated by Twitter. We managed to parse the information and extract the data that we need to create our game tiles. The next step is to work on the visuals of these tiles.
In this video we will add more details to our assets and spread them throughout the stage. Building it in advance in a modular way to enable us to add more features in the next videos.
Video Transcript
00:00So this isn't exactly what we want we want our copy to be spread throughout the screen
00:05We wanted to more or less be centered throughout the screen
00:08So we want kind of we want to randomly assign our copy giving a small buffer
00:12Making sure that our copy won't be flushed to any corner
00:15So to do that I'm going to before we add our child to this before we add our sprite to the screen
00:21I'm going to set my x and y coordinates
00:23So first of all I want to give a buffer of 50 pixels making sure that my x has to be at least 50 and
00:29Then I'm going to use my math class to get a random number between zero and one so I could duplicate that by the remainder of
00:36The area of the screen that I want my flash to get into so I open and close a bracket
00:41And I'm going to take my stage stage with
00:45And I'm going to subtract from the width my text fields with to make sure that we take into account our text fields with
00:52And on top of that we want to subtract that 50 that we put for margin on the left side
00:56but we want to put a margin of 50 pixels on the right side as well, so I'm going to subtract another hundred and
01:03This should give me a number that's going to be in that range
01:06So if I run my application one more time
01:08We should see that my copy will not have will be far away from the from the margin and the reason why I'm on the
01:14Right side right now. We have more of a margin is because our text field is 120 pixels in width
01:18But a lot of times our copy is much less than that and currently our copy is not centered yet
01:24So the next step that what I want we want to do is actually set the Y to be similar
01:29So I'm just going to grab my Y X and copy that and set my Y to be the same thing
01:34So the only thing I would want to change in my Y though is to make sure that we're talking with heights and not widths
01:39And that should do the trick so now if I run my application one more time
01:45We should get our copy all spread throughout the screen
01:49Now let's let's add our let's add into our application now our graphics
01:54Let's add our graphics. How do we do that?
01:56First of all, we're going to take our sprite and we're going to add a few more things to it
02:00so we're going to go into our graphics of our sprite and we're going to begin a fill and
02:07Our fill color is going to be the color we got from our create element in the top
02:11And we want to make sure that our alpha is dot 5, you know, so we could see through the other elements as they overlap
02:18Perfect. Now the next step after we already have our begin fill set is to actually create our round rectangle
02:25So I'm going to next step draw a round rectangle and my positions
02:33I want it to be 0 for X and 0 for Y. I
02:36Want my width of my text fields? I want it to match the width of my text field
02:41So I'm just going to go directly to my text field and I'm going to ask for its width and same for the height
02:47I'm going to take my height and width and my ellipse width
02:50I don't really care about my ellipse height
02:52But I'm just going to set my ellipse width to be 10 and I'm going to let the default happen for the rest
02:57now last thing that we have to do before we finish completing our our element is actually to end our fill and
03:03We've ended our fill now
03:05So if we run our application one more time now
03:07We should be able to see now the graphics and we're getting much closer into our shapes now
03:11We could see that we have an issue here as our copy is not in the center
03:15It's flushed to the left, which is the default
03:18So what I want to do is I want to actually add before we add our text in I want to actually add a
03:24Default text format which would be used throughout our application. I'm just going to call it text format TF
03:30Now we have to actually create that variable
03:32So I'm going to go back up into my main and I'm just going to add another private variable which would be a text format
03:38And I'm going to go into my main itself. I'm going to set a few things for my text format
03:45First of all, we want to set a new text format
03:51After we create a new text format. The next thing I'd want to do is actually
03:55Is actually add one value we wanted to tell our text format to align to the center and to do that
04:01I'm going to use the text format align
04:06Align it will automatically then import in line 9 and then we could delete art delete that and if we wanted to now
04:14Actually, we could have gone and
04:16Then we would see the hints
04:19Okay, so now we set our text format align
04:22With the value that we wanted to do to do so we're good here and we could go back into our create element
04:28And as we already added our text format if we just run our application one more time our text fields should be now centered
