Vie Crypto Faucet and PTC
Showing posts with label Unity3D. Show all posts
Showing posts with label Unity3D. Show all posts

Best game engines for 2d mobile games development

Best game engines for 2D mobile games development

best 2d mobile gamedev engines

There are several game engines available that are well-suited for developing 2D mobile games. The choice of a game engine depends on your specific requirements, programming skills, and personal preferences. Here are some popular game engines for 2D mobile game development:

  1. Unity:

    • Unity is a versatile game engine that supports both 2D and 3D game development.
    • It has a large community and a vast asset store, making it easy to find resources and plugins.
    • Supports both C# and JavaScript for scripting.
  2. Godot Engine:

    • Godot is an open-source game engine that is user-friendly and lightweight.
    • Godot supports a variety of programming languages for making games, including the integrated language GDScript, C++ and C#. Additionally, the engine includes GDNative, a facility for creating bindings with other languages. Officially-supported GDNative languages include C and C++. GDScript is easy to learn for beginners.

    • Supports multiple platforms, including mobile.
  3. Cocos2d-x:

    • Cocos2d-x is a popular open-source framework for building 2D games.
    • It supports multiple platforms, including iOS and Android.
    • Programmed in C++, and it has bindings for other languages like JavaScript and Lua.
  4. Solar2D ( ex Corona SDK ) :

    • Solar2D is known for its simplicity and ease of use.
    • It uses the Lua scripting language, which is easy for beginners to pick up.
    • Good for rapid development and prototyping.
  5. LibGDX:

    • LibGDX is a Java-based game development framework.
    • It supports cross-platform development and is suitable for 2D games.
    • It allows developers to deploy games to Android, iOS, desktop, and more.
  6. Phaser:

    • Phaser is a fast and lightweight JavaScript framework for building 2D games in the browser.
    • It is suitable for mobile games using web technologies (HTML5, JavaScript, and Canvas).
  7. GameMaker Studio:

    • GameMaker Studio is a user-friendly platform that doesn't require extensive programming knowledge.
    • It has a drag-and-drop interface and supports its scripting language, GML (GameMaker Language).

When choosing a game engine, consider factors like your programming skills, the specific requirements of your game, the target platforms, and the community support. It's also a good idea to try out a few engines to see which one aligns best with your development workflow and preferences.

My personal favorite - Solar2D. Empty project size is just 116 KB ( Unity's 1.2GB ! ) so it can be run easily on cheap laptop. Also free version of ChatGPT generates nice Lua code because tech is old enough and Lua language is simple and easy to learn.

For example check out my logical 2D game on Google Play made with Solar2D game engine :

Einstein's Riddles Android Game in Google Play

Unity3D: Horizontal Layout Group - add cells in runtime

Trabla: Unity3D: Horizontal Layout Group - add cells in runtime


Unity3D Horizontal Layout Group - add cells in runtime tutorial

Solving Overview:

1. We need to create Container for cells ( e.g. panel )
2. Container: Add component Horizontal Layout Group
3. Container: Add script with public property for cell prefab
+ code to create (clone) instances from prefab in runtime

4. We need to create cell prefab - e.g. UI.Image or UI.Button
5. Cell Prefab: Add Layout Element component

6. Set reference in Container Script to Cell Prefab

Solving:

1. Create new Unity 2D project

Unity3D Horizontal Layout Group - add cells in runtime tutorial 1

Right mouse click on "Main Camera" ( "Hierarchy" view ), select UI -> Panel
- Unity will create objects - "Canvas"  with child object "Panel"

Unity3D Horizontal Layout Group - add cells in runtime tutorial 2

Unity3D Horizontal Layout Group - add cells in runtime tutorial 3



2. Click on "Panel" - in "Inspector" view click "Add Component"
- select "Layout"->"Horizontal Layout Group"
Unity3D Horizontal Layout Group - add cells in runtime tutorial 4

Unity3D Horizontal Layout Group - add cells in runtime tutorial 5


3. Create script for panel - select "panel" - Add Component -> "New Script" type script name
e.g. "PanelScript"

Unity3D Horizontal Layout Group - add cells in runtime tutorial 6

Unity3D Horizontal Layout Group - add cells in runtime tutorial 7

Open script in Code Editor and paste following code:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Events;

public class PanelScript : MonoBehaviour {

    //We will put here reference to prefab in Editor
    public GameObject CellPrefab;


    // Use this for initialization
    void Start () {

        for (int i=0; i < 6; i++) {

            GameObject newCell = Instantiate (CellPrefab) as GameObject;

            //If you add script to cell prefab
            // you can init public vars like this
            //CellScript cellScript = newCell.GetComponent<CellScript>();
            //cellScript.value1 = 1;
            //cellScript.value2 = "trololo";
            //etc.


            newCell.transform.SetParent(  this.gameObject.transform,  false);

        }


    }

    // Update is called once per frame
    void Update () {

    }
}



Unity3D Horizontal Layout Group - add cells in runtime tutorial 8


4. Right mouse click on "Panel"  -  UI->Image
 Now download image below and put it into "Assets" ("Project" view ) folder ( drag-n-drop image into assests )

Unity3D Horizontal Layout Group - add cells in runtime tutorial 9


5. Select "Image" in "Hierarchy" view and in "Inspector"
find field "Image"->"Source Image".
Drag and drop image from assets into field "Source Image" ( it displays "None(Sprite)" )

Unity3D Horizontal Layout Group - add cells in runtime tutorial 10

Unity3D Horizontal Layout Group - add cells in runtime tutorial 11

Unity3D Horizontal Layout Group - add cells in runtime tutorial 12



6.   Select "Image" and in  Inspector click "Add Component" - select "Layout"->"Layout Element"

Unity3D Horizontal Layout Group - add cells in runtime tutorial 13

Unity3D Horizontal Layout Group - add cells in runtime tutorial 14


Unity3D Horizontal Layout Group - add cells in runtime tutorial 15


7. In "Hierarchy" view  select and drag-n-drop "Image" element into "Project"->"Assests"
- Unity will create prefab "Image".
Delete "Image" object from "Hierarchy" - left click + delete button

Unity3D Horizontal Layout Group - add cells in runtime tutorial 16



8. Set reference in Container Script (Panel) to Cell Prefab (Image).

Unity3D Horizontal Layout Group - add cells in runtime tutorial 17


Unity3D Horizontal Layout Group - add cells in runtime tutorial 18

9. Run

Unity3D Horizontal Layout Group - add cells in runtime tutorial 19


Unity3D: Vertical Layout Group - add cells in runtime

Trabla: Unity3D: Vertical Layout Group - add cells in runtime


Unity3D Vertical Layout Group - add cells in runtime tutorial


Solving Overview:

1. We need to create Container for cells ( e.g. panel )
2. Container: Add component Vertical Layout Group
3. Container: Add script with public property for cell prefab
+ code to create (clone) instances from prefab in runtime

4. We need to create cell prefab - e.g. UI.Image or UI.Button
5. Cell Prefab: Add Layout Element component

6. Set reference in Container Script to Cell Prefab


Solving:

1. Create new Unity 2D project

Unity3D Vertical Layout Group - add cells in runtime tutorial 1

Right mouse click on "Main Camera" ( "Hierarchy" view ), select UI -> Panel
- Unity will create objects - "Canvas"  with child object "Panel"

Unity3D Vertical Layout Group - add cells in runtime tutorial 2

Unity3D Vertical Layout Group - add cells in runtime tutorial 3



2. Click on "Panel" - in "Inspector" view click "Add Component"
- select "Layout"->"Vertical Layout Group"

Unity3D Vertical Layout Group - add cells in runtime tutorial 4


Unity3D Vertical Layout Group - add cells in runtime tutorial 5


3. Create script for panel - select "panel" - Add Component -> "New Script" type script name
e.g. "PanelScript"

Unity3D Vertical Layout Group - add cells in runtime tutorial 6

Unity3D Vertical Layout Group - add cells in runtime tutorial 7

Open script in Code Editor and paste following code:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Events;

public class PanelScript : MonoBehaviour {

    //We will put here reference to prefab in Editor
    public GameObject CellPrefab;


    // Use this for initialization
    void Start () {

        for (int i=0; i < 6; i++) {
   
            GameObject newCell = Instantiate (CellPrefab) as GameObject;

            //If you add script to cell prefab
            // you can init public vars like this
            //CellScript cellScript = newCell.GetComponent<CellScript>();
            //cellScript.value1 = 1;
            //cellScript.value2 = "trololo";
            //etc.


            newCell.transform.SetParent(  this.gameObject.transform,  false);

        }


    }

    // Update is called once per frame
    void Update () {

    }
}


Unity3D Vertical Layout Group - add cells in runtime tutorial 8


Unity3D Vertical Layout Group - add cells in runtime tutorial 9


4. Right mouse click on "Panel"  -  UI->Image
 Now download image below and put it into "Assets" ("Project" view ) folder ( drag-n-drop image into assests )

Unity3D Vertical Layout Group - add cells in runtime tutorial 10


5. Select "Image" in "Hierarchy" view and in "Inspector"
find field "Image"->"Source Image".
Drag and drop image from assets into field "Source Image" ( it displays "None(Sprite)" )






6.   Select "Image" and in  Inspector click "Add Component" - select "Layout"->"Layout Element"






7. In "Hierarchy" view  select and drag-n-drop "Image" element into "Project"->"Assests"
- Unity will create prefab "Image".
Delete "Image" object from "Hierarchy" - left click + delete button




8. Set reference in Container Script (Panel) to Cell Prefab (Image).





9. Run



Unity3D canvas config for HD resolution ( 2D games )

Trabla: Unity3D canvas config for HD ( 720 x 1280 ) resolution ( 2D games )


Unity3D canvas config for HD resolution ( 2D games )


This tutorial explains how to proper config canvas (and camera) for HD resolution in 2d games.

Solving:

1. Run Unity3D, create new 2D project

Unity3D canvas config for HD resolution ( 2D games ) tutorial 1


2. Right mouse click on "Main Camera" - select "Panel". Canvas element with be created automatically.

Unity3D canvas config for HD resolution ( 2D games ) tutorial 2

3. Click on "Canvas" in Hierarchy windows.
Than set "Canvas Render Mode" to "Screen Space - Camera"

Unity3D canvas config for HD resolution ( 2D games ) tutorial 3

4. Drag-n-drop "Main Camera" into Canvas "Render Camera"

Unity3D canvas config for HD resolution ( 2D games ) tutorial 4

Unity3D canvas config for HD resolution ( 2D games ) tutorial 5


5. In Canvas Scaler (Script)
change Screen Match Mode to "Scale With Screen Size"

Unity3D canvas config for HD resolution ( 2D games ) tutorial 6

6. Set reference resolution - 720 x 1280  - HD

Unity3D canvas config for HD resolution ( 2D games ) tutorial 7


7. Save Project

Now you can add standart UI button and see how it looks in HD resolution

Unity3D canvas config for HD resolution ( 2D games ) tutorial 8