Mobile game level making

Source: Internet
Author: User

Welcome to Unity Learning,Unity training ,UnityEnterprise TrainingEducation Area, there are manyUnity3d Resources,Unity3d Training Video,Unity3d Tutorials,Unity3d Frequently Asked questions,Unity3d Project Source code, the "Dog Planing Learning Network" Unity's Ultimate Academy, dedicated to building the industry unity3d Training , learning the first brand.
Many mobile game levels are active and inactive
When a certain level is passed, the corresponding icon displays the active state or the inactive state when the screen is entered again.
Like Angry Birds.

The Unity3d built-in GUI system is used here
Before we draw the button we need to know which levels have been passed.
You can use Playerprefs to save the level information in Unity3d see Playerprefs
We use a Boolean array to identify the activation state of the level
var m_bactive:boolean[];

Read the playerprefs saved level information during initialization
True if passed or false if the level passes conditions depending on the specific game rules such as the time spent per off is less than 3 minutes for passing and so on
m_bactive = new Boolean[m_ileveltotals];
for (idx = 1; idx < m_ileveltotals; ++idx)
(Level pass condition)? M_BACTIVE[IDX] = True:m_bactive = false;m_bactive[0] = true;

The first level here is activated, or all levels are locked, and the scene is suppressed.
Through initialization, we already know the pass information of the level.
Before drawing the level icon we know that Unity3d's GUI has Guiskin and Guistyle
Guiskin can specify the style of multiple GUI
And Guistyle just for a GUI style
So we're going to define a guistyle for the level buttons.

var M_guistagebtn:guistyle;

And there is a picture of the active state and an inactive picture

var m_texlocked:texture2d;
var m_texactive:texture2d;

Below start to draw the level icon here assume that the current page has 16 off to draw 16 icons 4 rows 4 columns

Col_1
for (i = 0; I < + + + 4)
{
if (!m_beasyactive)
M_GuiStageBtn.normal.background = m_texlocked;
Else
M_GuiStageBtn.normal.background = m_texactive;
if (GUI. Button (Rect (Bayi, m_guistagebtn), "" ","
{
if (!m_beasyactive)
Return
if (m_beffectactive)
Audio. Playoneshot (G_buttondownclip);
G_icurrentlevel = i + 1;
Loadselectlevel (G_icurrentlevel);
}
}
Col_2
for (i = 1; i < + + + 4)
{
if (!m_beasyactive)
M_GuiStageBtn.normal.background = m_texlocked;
Else
M_GuiStageBtn.normal.background = m_texactive;
if (GUI. Button (Rect (165, I-1) + (+/-), "", M_GUISTAGEBTN))
{
if (!m_beasyactive)
Return
if (m_beffectactive)
Audio. Playoneshot (G_buttondownclip);
G_icurrentlevel = i + 1;
Loadselectlevel (G_icurrentlevel);
}
}
Col_3
for (i = 2; i <; i + = 4)
{
if (!m_beasyactive)
M_GuiStageBtn.normal.background = m_texlocked;
Else
M_GuiStageBtn.normal.background = m_texactive;
if (GUI. Button (Rect (i-2) + (+/-), "", M_GUISTAGEBTN)
{
if (!m_beasyactive)
Return
if (m_beffectactive)
Audio. Playoneshot (G_buttondownclip);
G_icurrentlevel = i + 1;
Loadselectlevel (G_icurrentlevel);
}
}
Col_4
for (i = 3; I < + + + + 4)
{
if (!m_beasyactive)
M_GuiStageBtn.normal.background = m_texlocked;
Else
M_GuiStageBtn.normal.background = m_texactive;
if (GUI. Button (Rect (345, i-3) + (+/-), "", M_GUISTAGEBTN))
{
if (!m_beasyactive)
Return
if (m_beffectactive)
Audio. Playoneshot (G_buttondownclip);
G_icurrentlevel = i + 1;
Loadselectlevel (G_icurrentlevel);
}
}

Of course you can do this before drawing the if (GUI. Button (...)) Previously, the activation state of the button was processed directly according to the activation state of the current level plus gui.enabled = m_bactive;
It's simple, but it's easy to imagine when you're looping. This is just a drawing of 16 icons If you draw a lot and then you can easily go wrong with hard mode expert mode.
But the principle is basically the same.
Using Unity3d's built-in GUI is a headache when drawing the GUI, and the GUI's drawing function Ongui is a large consumption plus drawcall rendering efficiency.
In the application of mobile games are not to be ignored.

For more information, please visit the "Dog Planing Learning Network" Unity Ultimate Academy


Statement: This document comes from the "Dog Planing Learning Network" Community-unity Extreme College, is a self-published Unity3d study articles, if anything violates your relevant interests, please communicate with the official, we will deal with the real-time.


Mobile game level making

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.