질문과 답변

Extra Form
class Sprite_Base < Sprite
  #--------------------------------------------------------------------------
  # ● 애니메이션 스프 라이트 만들기
  #--------------------------------------------------------------------------
  def make_animation_sprites
    @ani_sprites = []
    if @use_sprite && !@@ani_spr_checker.include?(@animation)
      16.times do
        sprite = ::Sprite.new(viewport)
        sprite.visible = false
        @ani_sprites.push(sprite)
      end
      if @animation.position == 3
        @@ani_spr_checker.push(@animation)
      end
    end
    @ani_duplicated = @@ani_checker.include?(@animation)
    if !@ani_duplicated && @animation.position == 3
      @@ani_checker.push(@animation)
    end
  end
end



class Sprite_Character < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 말풍선 아이콘의 시작
  #--------------------------------------------------------------------------
  def start_balloon
    dispose_balloon
    @balloon_duration = 8 * balloon_speed + balloon_wait
    @balloon_sprite = ::Sprite.new(viewport)
    @balloon_sprite.bitmap = Cache.system("Balloon")
    @balloon_sprite.ox = 16
    @balloon_sprite.oy = 32
    update_balloon
  end



위의 두 스크립트는 vxa의 기본스크립트에서 발췌한 겁니다.

두 스크립트에서 보시다시피, 그냥 Sprite.new가 아닌, :: 연산자를 앞에 붙이고 스프라이트 객체를 생성하는데요.
여기서 ::의 역할이 뭔지 궁금합니다.
Sprite.new 와 ::Sprite.new 의 차이가 뭔지 궁금합니다.

도와주시면 정말 감사드릴게요. 검색해봐도 어디서도 답이 안 나오네요.

Comment '5'
  • profile
    습작 2014.10.07 13:07
    http://stackoverflow.com/questions/10482772/rubys-double-colon-operator-usage-differences
    절대경로와 상대경로의 차이라네요.
    저 자신도 야매야매해서 이 경우가 정확히 맞는건지는 잘 모르겠네요.
  • ?
    일단 2014.10.07 16:01
    감사합니다! 말씀해주신 설명대로네요.
    영문으로 추가 검색해봐도 설명대로 나와있어서- 맞는 거 같습니다.

    질문 1시간만에 답변해주시다니 ㅠ
    이렇게 빨리 답변이 올라올 줄은 몰랐네요.

    다시 한 번 답변 감사합니다!
  • ?
    일단 2014.10.07 19:18
    ::를 뭔지 알아서 매우 기뻤는데.. ㅠㅠ
    또 하나의 궁금증이...

    이거 대체 왜 ::를 붙였는지.. 혹시 아시나요?
    그냥 Sprite.new해도 전혀 상관없는 거 같은데... 왜 굳이 ::를 붙였을까요?
  • profile
    습작 2014.10.07 19:22
    글쎄요, 여타 Scene 클래스에서는 그대로 사용하던데 Sprite_Base 클래스 등은 Sprite의 하위 클래스라서 명확히 하고자 했을까요?
    저는 잘 모르겠네요.;;
  • ?
    일단 2014.10.07 19:40
    그렇군요.
    답변 감사합니다!

List of Articles
종류 분류 제목 글쓴이 날짜 조회 수
공지 묻고 답하기 가이드 습작 2014.06.14 12441
Board Pagination Prev 1 ... 6 7 Next
/ 7