2014-12-14 5 views
3

나는 최근 HaxeFlixel 주변에 바이올린을 시작했습니다를 진짜 간단한 게임을 만들려고 할 때,이 에러를 본적이클래스는 클래스 가져 오기 예외를 찾을 수 없습니다 : (OpenFL + Flixel 라이브러리 포함) Haxe

source/PlayState.hx:10: characters 7-16 : Class not found : GameLogic 

이제 게임이나 기타 프로그래밍에 처음으로 참여한 것은 아니지만이 오류가 왜 나타나는지 실마리가 없습니다. 우선 GameLogic은 클래스가 아니며 패키지입니다. 내 GameLogic 패키지에서 기본 Player 클래스를 가져 오려고하면 오류가 발생합니다.

내 기본 플레이어 클래스 :

package GameLogic; 

import flixel.FlxSprite; 
import flixel.util.FlxColor; 

class Player extends FlxSprite { 

    public function new(X:Float=0, Y:Float=0) { 
     super(X, Y); 
     makeGraphic(32, 32, FlxColor.WHITE); 
    } 

} 

예외가 발생합니다 :

 import GameLogic.Player; 

class PlayState extends FlxState{ 

    private var p:Player; 

    override public function create():Void{ 
     p = new Player(20, 20); 
     add(p); 
     super.create(); 
    } 

내 [관련] 디렉토리 구조 다음 Haxe docs 상태로

| src 
    | | GameLogic 
    | | | Player.hx 
    | | PlayState.hx 
+0

처음으로 게임 로직을 소문자로 쓰면 게임 이름이 게임 로직으로 인식 될 것입니다. – JensG

답변

3

:

Each part of the path in package names must begin with a lower case letter and, like all types, type names in packages must begin with an upper case letter. Hence My.Pack is an invalid package, as is my.Pack. Similarly, my.pack.e would not be a valid type name or import

패키지 이름을 gameLogic으로 소문자 G으로 지정해야 올바른 패키지 이름으로 인식되어야합니다. up-to-date docs의 관련 부분이 약간 더 복잡 읽을 수 있지만 본질적으로이 문제에 관해서는 같은 의미 : 이름 확인을 위해

Define: Module

All Haxe code is organized in modules, which are addressed using paths. In essence, each .hx file represents a module which may contain several types. A type may be private, in which case only its containing module can access it.

The distinction of a module and its containing type of the same name is blurry by design. In fact, addressing haxe.ds.StringMap can be considered shorthand for haxe.ds.StringMap.StringMap. The latter version consists of four parts:

  1. the package haxe.ds
  2. the module name StringMap
  3. the type name StringMap
  4. the type parameter Int

알고리즘은 더 자세히 here을 설명한다.

+1

아, ㅎ ㅎ ... 물론 그렇습니다! 나는 ... 어, 알았어! 나는 너를 시험해보고 있었다. 잘 했어! (미안하지만 내 어리 석음에 대한 감사) –