Don't like ads? PRO users don't see any ads ;-)
Guest

Broken Glow event

By: Ukyuu on Aug 20th, 2012  |  syntax: Game Maker  |  size: 2.09 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /////////////////
  2. /// scripts ////
  3. ///////////////
  4.  
  5. // glow_prepare(sprite, subimg, color)
  6.  
  7. surface_free(obj_control.glow_surface);
  8.  
  9. var w, h;
  10. w = sprite_get_width(argument0);
  11. h = sprite_get_height(argument0);
  12.  
  13. obj_control.glow_surface = surface_create(w/2, h/2);
  14. surface_set_target(obj_control.glow_surface);
  15. draw_clear_alpha(0, 0);
  16.  
  17. texture_set_interpolation(1);
  18. draw_set_blend_mode(bm_add);
  19. repeat 15
  20. begin
  21.     draw_sprite_stretched_ext(argument0, argument1, 0, 0, w/2, h/2, argument2, 1);
  22. end;
  23. draw_set_blend_mode(bm_normal);
  24. texture_set_interpolation(0);
  25.  
  26. surface_reset_target();[/code]
  27.  
  28. // Glow_draw(sprite, subimg, x, y, alpha);
  29.  
  30. draw_set_color(c_white);
  31. var i, a, o;
  32. i = -1;
  33. repeat 11
  34. begin
  35.     i += 1;
  36.  
  37.     a = lengthdir_x(argument4, 270+180*(i/9));
  38.     o = (i-6)*4 + 24;
  39.     draw_surface_ext(obj_control.glow_surface, argument2+o-18, argument3, 2, 2, 0, c_white, a);
  40.     draw_surface_ext(obj_control.glow_surface, argument2, argument3+o-18, 2, 2, 0, c_white, a);    
  41. end;    
  42. draw_sprite(argument0, argument1, argument2, argument3);[/code]
  43.  
  44. ////////////////////
  45. ///// objects //////
  46. ////////////////////
  47.  
  48. /// obj_control ///
  49. //create event (!)
  50.  
  51. glow_surface = surface_create(4, 4);    // Dummy surface
  52. glow_sine = 0;                          // Sine variable for the pulse effect
  53. glow_id = -1;                                   // ID that keeps the current glowing object[/code]
  54.  
  55. // draw event (!)
  56.  
  57. if glow_id != -1                                // If a glowing object is selected
  58. {
  59.         glow_sine += 0.075;                                                     // Make sure the sine is moving
  60. alpha = 0.1 + (sin(glow_sine)+1)/2 * 0.15;      // Calculate alpha
  61.  
  62. glow_draw(glow_id.sprite_index, 0, glow_id.x, glow_id.y, alpha);
  63. }[/code]
  64.  
  65. [code]
  66. Create event for objects that will be selectable
  67.  
  68. color = c_red;                          // Define glow color for this object[/code]
  69.  
  70.  
  71. /// obj_43_txt ///
  72. // create event
  73. color = c_red; // Define glow color for this object
  74.  
  75. // Mouse enter event
  76. /// Glow Effect
  77. glow_prepare(sprite_index, 0, color);// Prepare glow surface
  78. obj_control.glow_id = id;// Set the controller variable to this ID     
  79.  
  80. /// mouse leave event
  81.  
  82. obj_control.glow_id = -1;                       // Reset ID variable