You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
3.0 KiB

7 years ago
  1. import DentedPixel;
  2. public var grumpy:Texture2D;
  3. public var beauty:Texture2D;
  4. private var w:float = Screen.width;
  5. private var h:float = Screen.height;
  6. private var buttonRect1:LTRect;
  7. private var buttonRect2:LTRect;
  8. private var buttonRect3:LTRect;
  9. private var buttonRect4:LTRect;
  10. private var grumpyRect:LTRect;
  11. private var beautyTileRect:LTRect;
  12. function Start () {
  13. w = Screen.width;
  14. h = Screen.height;
  15. buttonRect1 = new LTRect(0.10*w, 0.8*h, 0.25*w, 0.14*h );
  16. buttonRect2 = new LTRect(1.2*w, 0.8*h, 0.2*w, 0.14*h );
  17. buttonRect3 = new LTRect(0.35*w, 0.0*h, 0.3*w, 0.2*h );
  18. buttonRect4 = new LTRect(0.0*w, 0.4*h, 0.3*w, 0.2*h, 1.0, 15.0 );
  19. grumpyRect = new LTRect(0.5*w - grumpy.width/2.0, 0.5*h - grumpy.height/2.0, grumpy.width, grumpy.height );
  20. beautyTileRect = new LTRect(0,0,1,1 );
  21. LeanTween.move( buttonRect2, Vector2(0.55*w, buttonRect2.rect.y), 0.7f ).setEase(LeanTweenType.easeOutQuad);
  22. }
  23. function OnGUI(){
  24. var staticRect:Rect = Rect(0.0*w, 0.0*h, 0.2*w, 0.14*h);
  25. if(GUI.Button( staticRect, "Move Cat")){
  26. if(LeanTween.isTweening(grumpyRect)==false){ // Check to see if the cat is already tweening, so it doesn't freak out
  27. var orig:Vector2 = Vector2( grumpyRect.rect.x, grumpyRect.rect.y );
  28. LeanTween.move( grumpyRect, Vector2( 1.0*w - grumpy.width, 0.0*h ), 1.0).setEase(LeanTweenType.easeOutBounce) ;
  29. LeanTween.move( grumpyRect, orig, 1.0 ).setEase(LeanTweenType.easeOutBounce).setDelay(1.0);
  30. }
  31. }
  32. GUI.DrawTexture( grumpyRect.rect, grumpy);
  33. if(GUI.Button(buttonRect1.rect, "Scale Centered")){
  34. LeanTween.scale( buttonRect1, Vector2(buttonRect1.rect.width, buttonRect1.rect.height) * 1.2, 0.25 ).setEase(LeanTweenType.easeOutQuad);
  35. LeanTween.move( buttonRect1, Vector2(buttonRect1.rect.x-buttonRect1.rect.width*0.1, buttonRect1.rect.y-buttonRect1.rect.height*0.1), 0.25).setEase(LeanTweenType.easeOutQuad) ;
  36. }
  37. if(GUI.Button(buttonRect2.rect, "Scale")){
  38. LeanTween.scale( buttonRect2, Vector2(buttonRect2.rect.width, buttonRect2.rect.height) * 1.2, 0.25 ).setEase(LeanTweenType.easeOutBounce);
  39. }
  40. staticRect = Rect(0.76*w, 0.53*h, 0.2*w, 0.14*h);
  41. if(GUI.Button( staticRect, "Flip Tile")){
  42. LeanTween.move( beautyTileRect, Vector2( 0, beautyTileRect.rect.y + 1 ), 1.0 ).setEase(LeanTweenType.easeOutBounce);
  43. }
  44. GUI.DrawTextureWithTexCoords( Rect(0.8*w, 0.5*h - beauty.height/2.0, beauty.width*0.5, beauty.height*0.5 ), beauty, beautyTileRect.rect);
  45. if(GUI.Button(buttonRect3.rect, "Alpha")){
  46. LeanTween.alpha( buttonRect3, 0.0, 1.0 ).setEase(LeanTweenType.easeOutQuad);
  47. LeanTween.alpha( buttonRect3, 1.0, 1.0 ).setEase(LeanTweenType.easeOutQuad).setDelay(1.0);
  48. }
  49. GUI.color.a = 1.0; // Reset to normal alpha, otherwise other gui elements will be effected
  50. if(GUI.Button(buttonRect4.rect, "Rotate")){
  51. LeanTween.rotate( buttonRect4, 150.0, 1.0 ).setEase(LeanTweenType.easeOutElastic);
  52. LeanTween.rotate( buttonRect4, 0.0, 1.0 ).setEase(LeanTweenType.easeOutElastic).setDelay(1.0);
  53. }
  54. GUI.matrix = Matrix4x4.identity; // Reset to normal rotation, otherwise other gui elements will be effected
  55. }