Player Ships

5 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€46.38
List Price:  €64.93
You save:  €18.55
£39.89
List Price:  £55.85
You save:  £15.96
CA$68.39
List Price:  CA$95.75
You save:  CA$27.36
A$75.62
List Price:  A$105.88
You save:  A$30.25
S$67.65
List Price:  S$94.72
You save:  S$27.06
HK$390.63
List Price:  HK$546.91
You save:  HK$156.28
CHF 45.32
List Price:  CHF 63.46
You save:  CHF 18.13
NOK kr540.83
List Price:  NOK kr757.20
You save:  NOK kr216.37
DKK kr346.01
List Price:  DKK kr484.44
You save:  DKK kr138.43
NZ$83.08
List Price:  NZ$116.32
You save:  NZ$33.23
د.إ183.61
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,489.47
List Price:  ৳7,685.71
You save:  ৳2,196.23
₹4,174.70
List Price:  ₹5,844.92
You save:  ₹1,670.21
RM236.90
List Price:  RM331.68
You save:  RM94.78
₦70,962.30
List Price:  ₦99,352.90
You save:  ₦28,390.60
₨13,872.15
List Price:  ₨19,422.12
You save:  ₨5,549.97
฿1,835.14
List Price:  ฿2,569.35
You save:  ฿734.20
₺1,612.71
List Price:  ₺2,257.93
You save:  ₺645.21
B$257.06
List Price:  B$359.91
You save:  B$102.84
R919.21
List Price:  R1,286.96
You save:  R367.75
Лв90.71
List Price:  Лв127.01
You save:  Лв36.29
₩68,279.30
List Price:  ₩95,596.49
You save:  ₩27,317.18
₪186.20
List Price:  ₪260.69
You save:  ₪74.49
₱2,872.25
List Price:  ₱4,021.38
You save:  ₱1,149.12
¥7,785.79
List Price:  ¥10,900.73
You save:  ¥3,114.94
MX$837.71
List Price:  MX$1,172.87
You save:  MX$335.15
QR181.98
List Price:  QR254.79
You save:  QR72.81
P681.01
List Price:  P953.47
You save:  P272.46
KSh6,621.46
List Price:  KSh9,270.57
You save:  KSh2,649.11
E£2,369.41
List Price:  E£3,317.36
You save:  E£947.95
ብር2,858.54
List Price:  ብር4,002.19
You save:  ብር1,143.64
Kz41,809.30
List Price:  Kz58,536.37
You save:  Kz16,727.06
CLP$46,240.75
List Price:  CLP$64,740.75
You save:  CLP$18,500
CN¥361.16
List Price:  CN¥505.65
You save:  CN¥144.49
RD$2,895.12
List Price:  RD$4,053.41
You save:  RD$1,158.28
DA6,726.94
List Price:  DA9,418.25
You save:  DA2,691.31
FJ$113.51
List Price:  FJ$158.92
You save:  FJ$45.41
Q388.49
List Price:  Q543.91
You save:  Q155.42
GY$10,421.54
List Price:  GY$14,591
You save:  GY$4,169.45
ISK kr6,972.10
List Price:  ISK kr9,761.50
You save:  ISK kr2,789.40
DH500.60
List Price:  DH700.89
You save:  DH200.28
L887.29
List Price:  L1,242.28
You save:  L354.98
ден2,857.41
List Price:  ден4,000.60
You save:  ден1,143.19
MOP$400.79
List Price:  MOP$561.14
You save:  MOP$160.35
N$921.79
List Price:  N$1,290.58
You save:  N$368.79
C$1,832.69
List Price:  C$2,565.92
You save:  C$733.22
रु6,654.99
List Price:  रु9,317.52
You save:  रु2,662.52
S/185.34
List Price:  S/259.50
You save:  S/74.15
K193.05
List Price:  K270.29
You save:  K77.23
SAR187.48
List Price:  SAR262.49
You save:  SAR75.01
ZK1,362.81
List Price:  ZK1,908.05
You save:  ZK545.23
L230.78
List Price:  L323.12
You save:  L92.33
Kč1,156.66
List Price:  Kč1,619.42
You save:  Kč462.75
Ft17,987.75
List Price:  Ft25,184.29
You save:  Ft7,196.54
SEK kr541.71
List Price:  SEK kr758.43
You save:  SEK kr216.72
ARS$44,114.95
List Price:  ARS$61,764.46
You save:  ARS$17,649.51
Bs345.50
List Price:  Bs483.72
You save:  Bs138.22
COP$194,137.21
List Price:  COP$271,807.63
You save:  COP$77,670.42
₡25,482.48
List Price:  ₡35,677.52
You save:  ₡10,195.03
L1,227.34
List Price:  L1,718.38
You save:  L491.03
₲374,060
List Price:  ₲523,713.94
You save:  ₲149,653.93
$U1,921.90
List Price:  $U2,690.81
You save:  $U768.91
zł199.36
List Price:  zł279.12
You save:  zł79.76
Already have an account? Log In

Transcript

Hillier In this lecture, we'll add more player shapes to the game, you'll be able to select any one of the shapes in the menu and then play with it. So let's get to it. First of all, I'll go to sprites and open as player, we need to import the other player images into this one Sprite. So I'll click on Import and go to my images folder. Here I have these three shape images. So I'll select all three of them and click Open.

They'll be added to the sprite as sub images. Now we'll set the speed to zero so that it doesn't animate. Now we'll go to objects. Under menu I'll create a new object and name it menu manager. This is just a background object for the menu role. Now in the object, I'll add the Create event.

And here I'll add the variable action. Now let me explain the difference between an instance variable and a global variable. When you create a simple variable using this action, it creates Here's an instance variable. So you can only access that variable as long as the instance isn't the role. So if you destroy the instance or change the rule, the variable will no longer be accessible. So if I make a variable in the menu manager object, which only exists in the menu, I won't be able to access that variable in the game row.

So to do that, we have to create a global variable, you can access a global variable from anywhere at any time after it was created. So even after the instance is destroyed, you still have access to the global variable. And to create a global variable, you have to type global and dogs before the variable name. So we'll create a global variable that will show the image index of the selected ship. So I'll enter the variable name here. And now we'll go back to objects under menu I'll create an object and name it or ship selector.

This will be used for selecting a shape image. So this object will have the player sprite Now we'll open the menu room. Here replace an instance of our menu manager. And now we'll place instances of ownership selector one for each year. Now we'll double click on the second instance. These are the instance properties.

Now here I'll increase the frame of this instance, also known as the image index. And now for the third instance as let the third frame. So these are instances of the same object, but they're drawing different images from the same Sprite. I also increased the gap between them. And now I'll close the row. Now back in the ships lecture object, I'll add the mouse left pressed event.

Here we won't this instances image index to be applied to a global variable. So I'll add the variable action. In the name I'll enter the global variable and in the value all Imagine that. So this way you can change the selected image index. Now I'll add the play audio action. I click here and play the SMD click sound.

Now I'll add the step event. Now here we're going to check if this instances image index was selected. In that case, we set the alpha to one, otherwise the alpha should be 0.5. So I'll add an if condition, the variable v, which again is the global player image index variable, we check if the global variable is equal to this consensus image index. So that means that this ship image is selected. So in that case, I'll simply set the alpha to one and now we'll add the L section.

So if this ship image is not selected, I'll set the alpha to 0.5. So this way, the selected ship image will be highlighted. Now we want a global variable to be used by the player. So I'll open or player I'll go to its creative. And now here I'll add the variable action at the top of the event. Here, I'll set the image index variable, and its value will be the global player image index.

So the image index that you selected in the menu will be applied to the player's image index in the game. So now around the game, you can see the three player shifts here and that the first one is selected. So I'll select the second one and hit play. And you can see the selected ship in the game. So the feature is working but there's a small bug. If I get the speed power, you'll see that the trail is still using the old image.

So we need to apply the global image index to the trail object as well. So I'll open open layer trail and go to its create event. We'll do the same thing here that we did in the players creative and so the selected image index will be applied to the trail as well and This eliminates the bug And now I have a challenge for you. If I select a shape, then close again and then run it again, it will be reset back to the first one. So your challenge is to save the selected image index to an i&i file, and then load it in the creative edge of menu manager. This way the game will save the player selected share.

So if you face any issues doing that or have any questions, do let me know. And now let's move on to the next lecture.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.