Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

TypeScript

akimgacem edited this page Jul 4, 2016 · 6 revisions

Getting started with LayaAir TypeScript

TypeScript is a free and open source programming language developed and maintained by Microsoft. Designed for development of large applications and transcompiles to JavaScript. More info at: typescriptlang

Software requirement:

Installation Guide:

  1. Integrated development environment * Visual Studio 2015 :

    • Go to Macros > Edit Macros... in tab menu
    • Click on Add Button, and choose a name (cf. LayaAir_AS3)
    • Go to Entries and enter the folowing command:

    SaveAllModified

    RunProcessCaptured|F:\LAYABOX\dev\tools\Laya.Flash\laya.js.exe;"$(ProjectPath);iflash=false"


    • Open a sample project from our git : layaair/samples/as/LayaAirSamples.as3proj
    • Run it with Alt+F5 shortcut or go to Macro > LayaAir_AS3
* LayaFlash IDE :
 - Go to `Macros > Edit Macros...` in tab menu
 - create sample `*.laya` project
  1. Sample code:
  • Hello Laya :
/// <reference path="../../libs/LayaAir.d.ts" />
class Sprite_DisplayImage{

    constructor(){
        Laya.init(550, 400);
        Laya.stage.scaleMode = "showall";

        var ape = new Laya.Sprite();
        //Loading our monkey
        ape.loadImage("res/apes/monkey2.png", 220, 128);

        Laya.stage.addChild(ape);
    }
}
new Sprite_DisplayImage();
  • Display 2D image :
/// <reference path="../../libs/LayaAir.d.ts" />
class Sprite_DisplayImage{

    constructor(){
        Laya.init(550, 400);
        Laya.stage.scaleMode = "showall";

        var ape = new Laya.Sprite();
        //Loading our monkey
        ape.loadImage("res/apes/monkey2.png", 220, 128);

        Laya.stage.addChild(ape);
    }
}
new Sprite_DisplayImage();
  • 3D display :
/// <reference path="../../libs/LayaAir.d.ts" />
class Sprite_DisplayImage{

    constructor(){
        Laya.init(550, 400);
        Laya.stage.scaleMode = "showall";

        var ape = new Laya.Sprite();
        //Loading our monkey
        ape.loadImage("res/apes/monkey2.png", 220, 128);

        Laya.stage.addChild(ape);
    }
}
new Sprite_DisplayImage();

Further more:

Clone this wiki locally