简体   繁体   中英

access the jth turtle

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM