Advertisement
Amabadaguesy

Untitled

Jan 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var HomeState = {
  2.   init: function (message) {
  3.     this.message = 'Classic Memory Match';
  4.   },
  5.  
  6.   create: function () {
  7.     // this.state.start('GameState');
  8.  
  9.    
  10.  
  11.   var spriteAttributes = { sprite1: { position: { y:0 } }, sprite2: { position: { x: 50 } } };
  12.  
  13.     for (var key in Object.keys(spriteAttributes)) {
  14.       spriteName = Object.keys(spriteAttributes)[key];
  15.             console.log(spriteAttributes[spriteName].position.y)
  16.            
  17.             var spriteCreation = function (spriteAttributes, sprite) {
  18.             if (!spriteAttributes.position) {
  19.               spriteAttributes.position = {};
  20.             }
  21.             if (!spriteAttributes.position.x) {
  22.               spriteAttributes.position.x = 0;
  23.             }
  24.             if (!spriteAttributes.position.y) {
  25.               spriteAttributes.position.y = 0;
  26.             }
  27.             //sprite anchor
  28.             if (!spriteAttributes.anchor) {
  29.               spriteAttributes.anchor = {};
  30.            }
  31.             if (!spriteAttributes.anchor.x) {
  32.               spriteAttributes.anchor.x = 0;
  33.             }
  34.             if (!spriteAttributes.anchor.y) {
  35.               spriteAttributes.anchor.y = 0;
  36.             }
  37.             //sprite scale
  38.             if (!spriteAttributes.scale) {
  39.               spriteAttributes.scale = {};
  40.            }
  41.             if (!spriteAttributes.scale.x) {
  42.               spriteAttributes.scale.x = 1;
  43.      
  44.             }
  45.             if (!spriteAttributes.scale.y) {
  46.               spriteAttributes.scale.y = 1;
  47.             }
  48.             //sprite pivoting
  49.             if (!spriteAttributes.pivot) {
  50.               spriteAttributes.pivot = {};
  51.            }
  52.             if (!spriteAttributes.pivot.x) {
  53.               spriteAttributes.pivot.x = 0;
  54.      
  55.             }
  56.             if (!spriteAttributes.pivot.y) {
  57.               spriteAttributes.pivot.y = 0;
  58.             }
  59.             //sprite rotation
  60.             if (!spriteAttributes.rotation) {
  61.               spriteAttributes.rotation = {};
  62.            }
  63.             if (!spriteAttributes.rotation.x) {
  64.               spriteAttributes.rotation.x = 0;
  65.      
  66.             }
  67.             if (!spriteAttributes.rotation.y) {
  68.               spriteAttributes.rotation.y = 0;
  69.             }
  70.             //sprite angle
  71.             if (!spriteAttributes.angle) {
  72.               spriteAttributes.angle = {};
  73.            }
  74.             if (!spriteAttributes.angle.x) {
  75.               spriteAttributes.angle.x = 0;
  76.      
  77.             }
  78.             if (!spriteAttributes.angle.y) {
  79.               spriteAttributes.angle.y = 0;
  80.             }
  81.            
  82.             game[sprite].position.x = spriteAttributes.position.x;
  83.       game[sprite].position.y = spriteAttributes.position.y;
  84.       game[sprite].anchor.x = spriteAttributes.anchor.x;
  85.       game[sprite].anchor.y = spriteAttributes.anchor.y;
  86.       game[sprite].scale.x = spriteAttributes.scale.x;
  87.       game[sprite].scale.y = spriteAttributes.scale.y;
  88.       game[sprite].pivot.x = spriteAttributes.pivot.x;
  89.       game[sprite].pivot.y = spriteAttributes.pivot.y;
  90.       game[sprite].rotation.x = spriteAttributes.rotation.x;
  91.       game[sprite].rotation.y = spriteAttributes.rotation.y;
  92.       game[sprite].angle.x = spriteAttributes.angle.x;
  93.       game[sprite].angle.y = spriteAttributes.angle.y;
  94.            
  95.      
  96.  
  97.    
  98.    
  99.  
  100.      
  101.  
  102.  
  103.  
  104.     };
  105.     //spriteCreation(spriteAttributes, 'Menu-Title');
  106.    
  107.   }
  108.  
  109. }
  110.    
  111. };  
  112.    
  113.  
  114.    
  115.  
  116.  
  117.     //   spriteCreation(spriteAttributes, 'Menu-Title');
  118.     //  }else{
  119.  
  120.  
  121.  
  122.    
  123.  
  124.      
  125.     //eval("(" + this.game.phaserConfig.assets.abraCommands.abraSprite.create + ")")(spriteAttributes, 'Menu-Title');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement