문제

In PencilCode, I hatch 10 turtles:

turtles = hatch 10

How to access only the jth turtle in the "turtles" set (for example only the first turtle)?

I want to apply functions, for example pen('red').rt(90).fd(100) to only one of the turtles in the set.

도움이 되었습니까?

해결책

The result from hatch is a jquery object, so you can access the jth turtle by using the jquery function eq(j).

For example

turtles = hatch 10
turtles.eq(5).pen(red).fd(100)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top