기능추가

F12로 일시정지하기

by windshy posted Jan 11, 2010
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form
출처 Zeriab
  1. #==============================================================================
  2. # ** Pausing with F12
  3. #------------------------------------------------------------------------------
  4. # Zeriab
  5. # Version 1.1
  6. # 2009-05-25 (Year-Month-Day)
  7. #------------------------------------------------------------------------------
  8. # * Version History :
  9. #
  10. #   Version 1.0 -------------------------------------------------- (2009-05-22)
  11. #   - First release
  12. #
  13. #   Version 1.1 -------------------------------------------------- (2009-05-25)
  14. #   - The pause image now appears immediately when F12 is pressed.
  15. #   - Transitions are cut short rather than restarted when F12 is pressed.
  16. #------------------------------------------------------------------------------
  17. # * Description :
  18. #
  19. #   This script changes the functionality of pressing F12 during the game
  20. #   from resetting the game to (un)pausing the game. A picture is displayed
  21. #   while the game is paused. (Having a picture is optional)
  22. #------------------------------------------------------------------------------
  23. # * License :
  24. #
  25. #   Copyright (C) 2009  Zeriab
  26. #
  27. #   This program is free software: you can redistribute it and/or modify
  28. #   it under the terms of the GNU Lesser Public License as published by
  29. #   the Free Software Foundation, either version 3 of the License, or
  30. #   (at your option) any later version.
  31. #
  32. #   This program is distributed in the hope that it will be useful,
  33. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  35. #   GNU Lesser Public License for more details.
  36. #
  37. #   For the full license see <http://www.gnu.org/licenses/>
  38. #   The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
  39. #   The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt
  40. #------------------------------------------------------------------------------
  41. # * Compatibility :
  42. #
  43. #   Is most likely not compatible with other F12 prevention scripts.
  44. #------------------------------------------------------------------------------
  45. # * Instructions :
  46. #
  47. #   Place this script anywhere above main.
  48. #   The image file 'pause' present in Graphics/Pictures is used.
  49. #   Note: No picture is shown if there is no 'pause' in Graphics/Pictures.
  50. #==============================================================================
  51.  
  52. #=============================================================================
  53. # ** Reset class (because it won't be defined until F12 is pressed otherwise)
  54. #=============================================================================
  55. class Reset < Exception
  56.  
  57. end
  58. #=============================================================================
  59. # ** Module Graphics
  60. #=============================================================================
  61. module Graphics
  62.   class << self
  63.     #-------------------------------------------------------------------------
  64.     # * Aliases Graphics.update and Graphics.transition
  65.     #-------------------------------------------------------------------------
  66.     unless self.method_defined?(:zeriab_f12_pause_update)
  67.       alias_method(:zeriab_f12_pause_update, :update)
  68.       alias_method(:zeriab_f12_pause_transition, :transition)
  69.     end
  70.     #-------------------------------------------------------------------------
  71.     # Change the update method so F12 toggles pause
  72.     #-------------------------------------------------------------------------
  73.     def update(*args)
  74.       # Try to update normally
  75.       begin
  76.         zeriab_f12_pause_update(*args)
  77.         return
  78.       rescue Reset
  79.         # Do nothing
  80.       end
  81.       # F12 has been pressed
  82.       done = false
  83.       # Store frame count
  84.       frame_count = Graphics.frame_count
  85.       # Show pause image
  86.       @sprite = Sprite.new
  87.       @sprite.z = 9999
  88.       begin
  89.         @sprite.bitmap = RPG::Cache.picture('pause')
  90.       rescue
  91.         @sprite.bitmap = Bitmap.new(32,32)
  92.       end
  93.       # Keep trying to do the update
  94.       while !done
  95.         begin
  96.           zeriab_f12_pause_update(*args)
  97.           done = true
  98.         rescue Reset
  99.           # Do Nothing
  100.         end
  101.       end
  102.       # F12 has been released, update until it is pressed again
  103.       while done
  104.         begin
  105.           zeriab_f12_pause_update(*args)
  106.         rescue Reset
  107.           done = false
  108.         end
  109.       end
  110.       # F12 has been pressed, keep trying to update
  111.       while !done
  112.         begin
  113.           zeriab_f12_pause_update(*args)
  114.           done = true
  115.         rescue Reset
  116.           # Do nothing
  117.         end
  118.       end
  119.       # F12 has been released, dispose pause image
  120.       @sprite.dispose
  121.       # Set proper frame count
  122.       Graphics.frame_count = frame_count
  123.     end
  124.     #-------------------------------------------------------------------------
  125.     # Changes the transition so it is cut short if F12 is pressed
  126.     #-------------------------------------------------------------------------
  127.     def transition(*args)
  128.       done = false
  129.       # Keep trying to do the transition
  130.       while !done
  131.         begin
  132.           zeriab_f12_pause_transition(*args)
  133.           done = true
  134.         rescue Reset
  135.           # Set transition length to 0 frames.
  136.           args[0] = 0
  137.         end
  138.       end
  139.     end
  140.   end
  141. end
  142. =====

    F12로 일시정지를 할수 있는 기능입니다

     

    사용방법 :

    예제처럼 F12버튼을 누를시, 특별한 그림을 나타내고싶을때에는

    pause그림에 사용할 그림을 graphics/pictures란에 저장합니다

    (※ 이때 저장할 그림 이름은 무조건 pause 여야 됩니다!)

    그리고 게임에 들어가서 F12 버튼을 누르면 일시정지가 되면서 그림이 뜹니다!

    예제를 첨부할테니 잘 따라해주시기 바랍니다 :)

     

    활용예제

     



Fatal error: Cannot access property sessionController::$lifetime in /web/old/xe/modules/session/session.controller.php on line 45