當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ElementRef.getContext方法代碼示例

本文整理匯總了TypeScript中@angular/core.ElementRef.getContext方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ElementRef.getContext方法的具體用法?TypeScript ElementRef.getContext怎麽用?TypeScript ElementRef.getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/core.ElementRef的用法示例。


在下文中一共展示了ElementRef.getContext方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: animateStance

 animateStance(playerClass){
   /* Set up canvas variables */
   var canvas = this.canvas.nativeElement;
   var character,characterImage;
   function gameLoop(){
     window.requestAnimationFrame(gameLoop);
     character.update();
     character.render();
   }
   switch(playerClass){
     case("Elementalist"):
       // Get canvas
       canvas.width = 125;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: 331,
         height: 162,
         image: characterImage,
         numberOfFrames: 3,
         ticksPerFrame: 4,
         loop: true
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-2/piccolo/piccolo-standing.png";
       break;
     case("Highwayman"):
       // Get canvas
       canvas.width = 99;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: 300,
         height: 162,
         image: characterImage,
         numberOfFrames: 3,
         ticksPerFrame: 5,
         loop: true
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-2/trunks/trunks-standing.png";
       break;
     case("Paragon"):
       // Get canvas
       canvas.width = 125;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: 373,
         height: 162,
         image: characterImage,
         numberOfFrames: 4,
         ticksPerFrame: 4,
         loop: true
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-2/gohan/gohan-standing.png";
       break;
   }
 }
開發者ID:JacobDeming,項目名稱:HotfixEngine,代碼行數:72,代碼來源:player2sprite.component.ts

示例2: animate

 animate(playerClass,playerAction){
   /* Set up canvas variables */
   var canvas = this.canvas.nativeElement;
   var character,characterImage;
   function gameLoop(){
     window.requestAnimationFrame(gameLoop);
     character.update();
     character.render();
   }
   /* Animate based on player and action */
   switch(playerClass){
     // elementalist : piccolo
     case ("Elementalist"):
       switch(playerAction){
         case("strike"):
           // Get canvas
           canvas.width = 150;
           canvas.height = 162;
           // Create sprite sheet
           characterImage = new Image();
           // Create sprite
           character = this.sprite({
             context: canvas.getContext("2d"),
             width: 450,
             height: 162,
             image: characterImage,
             numberOfFrames: 3,
             ticksPerFrame: 4
           });
           // Load sprite sheet
           characterImage.addEventListener("load", gameLoop);
           characterImage.src = "images/sprites/player-2/piccolo/piccolo-punch.png";
           break;
         case("special"):
           // Get canvas
           canvas.width = 190;
           canvas.height = 162;
           // Create sprite sheet
           characterImage = new Image();
           // Create sprite
           character = this.sprite({
             context: canvas.getContext("2d"),
             width: 380,
             height: 162,
             image: characterImage,
             numberOfFrames: 2,
             ticksPerFrame: 20
           });
           // Load sprite sheet
           characterImage.addEventListener("load", gameLoop);
           characterImage.src = "images/sprites/player-2/piccolo/piccolo-magic.png";
           break;
         case("defend"):
           // Get canvas
           canvas.width = 120;
           canvas.height = 162;
           // Create sprite sheet
           characterImage = new Image();
           // Create sprite
           character = this.sprite({
             context: canvas.getContext("2d"),
             width: 240,
             height: 162,
             image: characterImage,
             numberOfFrames: 2,
             ticksPerFrame: 20
           });
           // Load sprite sheet
           characterImage.addEventListener("load", gameLoop);
           characterImage.src = "images/sprites/player-2/piccolo/piccolo-defend.png";
           break;
         default:
           this.animateStance(playerClass);
       }
       break;
     // highwayman : trunks
     case ("Highwayman"):
       switch(playerAction){
         case("strike"):
           // Get canvas
           canvas.width = 185;
           canvas.height = 162;
           // Create sprite sheet
           characterImage = new Image();
           // Create sprite
           character = this.sprite({
             context: canvas.getContext("2d"),
             width: 556,
             height: 162,
             image: characterImage,
             numberOfFrames: 3,
             ticksPerFrame: 8
           });
           // Load sprite sheet
           characterImage.addEventListener("load", gameLoop);
           characterImage.src = "images/sprites/player-2/trunks/trunks-punch.png";
           break;
         case("special"):
           // Get canvas
           canvas.width = 190;
//.........這裏部分代碼省略.........
開發者ID:JacobDeming,項目名稱:HotfixEngine,代碼行數:101,代碼來源:player2sprite.component.ts

示例3: animateDefeat

 animateDefeat(playerClass){
   /* Set up canvas variables */
   var canvas = this.canvas.nativeElement;
   var character,characterImage;
   function gameLoop(){
     window.requestAnimationFrame(gameLoop);
     character.update();
     character.render();
   }
   switch(playerClass){
     case("Elementalist"):
       // Get canvas
       canvas.width = 162;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: canvas.width,
         height: canvas.height,
         image: characterImage,
         numberOfFrames: 1,
         ticksPerFrame: 10
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-1/piccolo/piccolo-defeat.png";
       break;
     case("Highwayman"):
       // Get canvas
       canvas.width = 177;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: canvas.width,
         height: canvas.height,
         image: characterImage,
         numberOfFrames: 1,
         ticksPerFrame: 10
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-1/trunks/trunks-defeat.png";
       break;
     case("Paragon"):
       // Get canvas
       canvas.width = 162;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: canvas.width,
         height: canvas.height,
         image: characterImage,
         numberOfFrames: 1,
         ticksPerFrame: 10
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-1/gohan/gohan-defeat.png";
       break;
   }
 }
開發者ID:JacobDeming,項目名稱:HotfixEngine,代碼行數:69,代碼來源:player1sprite.component.ts


注:本文中的@angular/core.ElementRef.getContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。