Spritekit이 부모를 변경하면 노드가 사라집니다. (Spritekit changing parent makes the node disappear)


문제 설명

Spritekit이 부모를 변경하면 노드가 사라집니다. (Spritekit changing parent makes the node disappear)

중앙에 노드(큰 사각형)가 있는 SKScene이 있습니다. 다른 노드가 있고 그 상위 노드를 장면 대신 mySquare로 변경하고 싶습니다.

myNode.moveToParent(mySquare)를 사용해 보았습니다. 노드 트리의 mySquare 아래에서 내 노드를 찾을 수 있으므로 작동하는 것 같습니다(for node in mySquare.children 올바른 노드 인쇄). 제 문제는 그 노드가 더 이상 보이지 않는다는 것입니다...

노드가 잘못된 위치를 가질 수 있는지 궁금해서 node.position = mySquare.convertPoint( node.position, fromNode: self). moveToParent 전에 노드의 위치를 임시 변수에 넣고 대신 이 위치를 변환하려고 시도했지만 작동하지 않았습니다. 그런 다음 mySquare의 앵커 포인트인 node.position = CGPoint(x: 0.5, y: 0.5)를 사용하여 간단히 mySquare의 중심에 노드를 배치하려고 시도했지만 노드는 여전히 사라졌습니다.

나는 스파크가 있는 노드에 SKEmitter를 넣어 위치를 테스트했습니다. 스파크는 노드의 부모가 Scene일 때 노드가 있었던 바로 그 위치에 있습니다. 즉, 올바른 위치에 있습니다. 하지만 노드가 없습니다.

이 문제를 해결하는 방법에 대한 아이디어가 있습니까?

시간 내주셔서 대단히 감사합니다.


추가 정보

제 노드 생성 방법입니다.

let object = SKSpriteNode(imageNamed: "myObject")
self.addChild(copy() as! SKSpriteNote)

터치에 맞게 위치를 설정했습니다(mySquare 내부를 터치할 때 생성).


참조 솔루션

방법 1:

Check the zPosition of your Node. Maybe it is hidden behind another element.

(by David GourdeStefan)

참조 문서

  1. Spritekit changing parent makes the node disappear (CC BY‑SA 2.5/3.0/4.0)

#coordinates #position #coordinate-transformation #sprite-kit #coordinate-systems






관련 질문

지구의 모든 좌표를 생성하시겠습니까? (Generate all coordinates of earth?)

Spritekit이 부모를 변경하면 노드가 사라집니다. (Spritekit changing parent makes the node disappear)

C++의 파일에서 읽은 값을 사용하는 데 도움이 되나요? (Some help using my values read from a file in C++?)

Java의 캔버스에 마우스가 그리는 좌표만 화면에 인쇄하려면 어떻게 해야 합니까? (How do I only print to the screen the coordinates of what the mouse is drawing on a canvas in Java?)

좌표가 영역 내부에 있는지 감지하는 방법은 무엇입니까? (How to detect if coordinate is inside region?)

대상 사각형을 포함하여 그리드의 두 사각형 사이의 거리를 계산하는 방법 (How do I calculate the distance between two squares on a grid, including the target square)

두 좌표 배열 간의 대응 관계 찾기 (Find correspondence between 2 arrays of coordinates)

Postgres 쿼리에서 포인트 유형을 사용하는 방법 (Postgres how to use point type in query)

좌표 목록으로 작업하고 싶습니다 [Haskell] (I want to work with a list of coordinates [Haskell])

C 프로그램에서 해당 선의 특정 점에서 특정 거리, 선 위의 점 찾기 (Find a point on a line, a certain distance from a certain point on that line in c program)

점이 있는 geopandas 데이터 프레임에서 다각형 만들기 (Creating a polygon from a geopandas dataframe with points)

Netlogo는 특정 xycor를 설정합니다. (Netlogo set specific xycor)







코멘트