Gosu
및 Chipmunk
보석을 사용하여 Ruby로 게임을 개발하고 있습니다. 나는 모든 Chipmunk
코드를 처리하는 다른 파일, Physics.rb
에서이 클래스에 접근 할 필요가 알고Ruby attr_accessor를 읽을 수 없습니다.
require 'gosu'
class HeroBullets
attr_accessor :y
def initialize(window)
@x = 20
@y = 0
end
end
: 나는 HeroBullets.rb
라는 이름의 파일에 다음과 같은 클래스가 있습니다.
require 'chipmunk'
load 'HeroBullets.rb'
class Physics
attr_accessor :play_area
def initialize(window)
@hBullets = Array.new(25)
@hBullets << HeroBullets.new(window)
@hBullets << HeroBullets.new(window)
end
그리고이 더 아래로 : : 맨
내가 가진
Physics.rb:112:in block in fire_arrow': undefined methody' for nil:NilClass
(NoMethodError) from Physics.rb:110:in each' from Physics.rb:110:infire_arrow'
from FileManager.rb:90:in fireHero' from .../lib/main.rb:90:inupdate' from .../lib/main.rb:129:in `'
여기 질문이 표시되지 않습니다. 또한 코드가 여전히 올바르지 않습니다. –
정확한 오류 메시지를 게시하십시오 –