Working with Actors

How do I change an Actor’s Costume?

You can use the {"func":"blockLooksNextCostume"} code block, or the {"func":"blockLooksSwitchCostume"} code block if you want to change it to a specific Costume.

Sample Code:
{"func":"registerSpriteTrigger","values":[],"containers":[],"next":{"func":"blockLooksNextCostume","values":[],"containers":[]}} Add to my Backpack

Sample Projects:    Aquarium, Splat!, Stepping Lion


How do I make an Actor spin?

Put the {"func":"blockMotionTurnCW"} code block inside a forever loop.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockControlForever","values":[],"containers":[{"func":"blockMotionTurnCW","values":[{"type":"string","value":"15"}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":".1"}],"containers":[]}}]}} Add to my Backpack

Sample Projects:    Spinning Top, Turning Art, Stamp and Swirl


How do I make an Actor move to a specific spot on the Stage?

Use the {"func":"blockMotionGlide"} code block or {"func":"blockMotionGoTo"} code blocks and specify the place on the Stage you want the Actor to move to.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockControlForever","values":[],"containers":[{"func":"blockMotionGoTo","values":[{"type":"number","value":"-200"},{"type":"number","value":"0"}],"containers":[],"next":{"func":"blockMotionGlide","values":[{"type":"number","value":"1"},{"type":"number","value":"200"},{"type":"number","value":"0"}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"1"}],"containers":[]}}}]}} Add to my Backpack

Sample Projects:    Blast Off!, Falling Apple


How do I make an Actor not go upside down?

Use the {"func":"blockMotionRotationStyle"} block to determine how Tynker handles rotation for your actors. You can make them rotate all around, disable rotation or just flip horizontally.


How do I make Actors move towards things?

Use the {"func":"blockMotionPointTowards"} block paired with a {"func":"blockMotionMove"} block inside a forever loop.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockControlForever","values":[],"containers":[{"func":"blockMotionPointTowards","values":[{"type":"string","value":"mouse-pointer"}],"containers":[],"next":{"func":"blockMotionMove","values":[{"type":"number","value":"1"}],"containers":[]}}]}} Add to my Backpack

Sample Projects:    Follow the Leader, Follow Me Butterfly


How do I stop an Actor from going off the Stage?

If you have a loop to control your Actor’s movement, you need to add the {"func":"blockMotionBounceOnEdge"} block inside that loop.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockControlForever","values":[],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"1"}],"containers":[],"next":{"func":"blockMotionBounceOnEdge","values":[],"containers":[]}}]}} Add to my Backpack

Sample Projects:    Tropical Bird, The Traveling Butterfly


When does an Actor use ‘messages’?

Messages are used to communicate between two Actors or the Stage and an Actor. Use the {"func":"blockControlBroadcast"} code block from one Actor to send a message. This will activate any code under the {"func":"registerBroadcastTrigger"} code block in the other Actor if the messages match. You can also use the {"func":"blockControlPostMessage"} block if you want to send a message to a specific Actor.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockControlBroadcast","values":[{"type":"string","value":"move"}],"containers":[]}} Add to my Backpack {"func":"registerBroadcastTrigger","values":[{"type":"string","value":"move"}],"containers":[],"next":{"func":"blockControlForever","values":[],"containers":[{"func":"blockMotionMove","values":[{"type":"number","value":"1"}],"containers":[],"next":{"func":"blockMotionBounceOnEdge","values":[],"containers":[]}}]}} Add to my Backpack

Sample Projects:    Snail Trails, Click the Bomb


When do I add different actions to the same Actor?

You can add different event blocks that will each activate their own set of code (the code attached below them) when their specific event happens. For example, in one Actor you might want certain code to execute when the left arrow is pressed, but different code to execute when the right arrow is pressed. You can use the {"func":"registerKeyTrigger"} twice in the same Actor’s code and attach different code blocks under each one.

Sample Projects:    Running Man, Paddle Ball


How do I make my Actors come forward? They are getting behind something.

You can use the {"func":"blockLooksGoFront"} and {"func":"blockLooksGoBack"} code blocks to bring an Actor all the way to the front or all the way to the back. Or, you can specify how many layers you want the Actor to come forward/backward with the {"func":"blockLooksMoveFront"} or {"func":"blockLooksMoveBack"}.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockLooksGoFront","values":[],"containers":[]}} Add to my Backpack

Sample Projects:    Cows vs. Aliens, Moody Face


How do I show or hide an Actor?

Use the {"func":"blockLooksShow"} or {"func":"blockLooksHide"} blocks inside the Actor’s code to make them appear or disappear on the Stage.

Sample Code:
{"func":"registerSpriteTrigger","values":[],"containers":[],"next":{"func":"blockLooksShow","values":[],"containers":[]}} Add to my Backpack {"func":"registerSpriteTrigger","values":[],"containers":[],"next":{"func":"blockLooksHide","values":[],"containers":[]}} Add to my Backpack

Sample Projects:    Shoot the Bird, Keeping Score


How do I save an Actor as my own TynkerBlock?

When you make your own Actors and give them code, you can save them as TynkerBlocks to use in other projects! To do so, just click on the Actor you want to make into a TynkerBlock, click on the “Advanced” tab, and click on “Save T.Block”.


How do I use code or Actors from one project in another project?

You can drag Actors, functions, and your own drawings into your backpack on the top right of the screen. This way, you are giving all your projects access to that object.


How do I create a conversation between two Actors?

Combine {"func":"blockLooksSay"} blocks with {"func":"blockControlWait"} blocks to make Actors say things and wait for the other Actor to respond before talking again.

Sample Code:
{"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockLooksSayFor","values":[{"type":"string","value":"Hello!"},{"type":"number","value":"2"}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"2.5"}],"containers":[],"next":{"func":"blockLooksSayFor","values":[{"type":"string","value":"Good, you?"},{"type":"number","value":"2"}],"containers":[]}}}} Add to my Backpack {"func":"registerFlagTrigger","values":[],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"2.5"}],"containers":[],"next":{"func":"blockLooksSayFor","values":[{"type":"string","value":"Hi! How are you?"},{"type":"number","value":"2"}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"2.5"}],"containers":[],"next":{"func":"blockLooksSayFor","values":[{"type":"string","value":"Good, thanks!"},{"type":"number","value":"2"}],"containers":[]}}}}} Add to my Backpack

Sample Projects:    Panda Meets Bear, Knock Knock!


How do I make copies of an Actor?

The {"func":"blockControlCloneActor"} code block will activate the code under {"func":"registerCloned"} in the specified Actor’s code. {"func":"blockControlDeleteActor"} will delete the clone when you’re done!

Sample Code:
{"func":"registerKeyTrigger","values":[{"type":"choice","value":"space"}],"containers":[],"next":{"func":"blockControlCloneActor","values":[{"type":"string","value":"self"}],"containers":[]}} Add to my Backpack {"func":"registerCloned","values":[],"containers":[],"next":{"func":"blockMotionGoTo","values":[{"type":"wrapper","func":"valueOpRandom","values":[{"type":"wrapper","func":"valueSensingScreenRight","values":[]},{"type":"wrapper","func":"valueSensingScreenLeft","values":[]}]},{"type":"wrapper","func":"valueOpRandom","values":[{"type":"wrapper","func":"valueSensingScreenBottom","values":[]},{"type":"wrapper","func":"valueSensingScreenTop","values":[]}]}],"containers":[],"next":{"func":"blockControlWait","values":[{"type":"number","value":"10"}],"containers":[],"next":{"func":"blockControlDeleteActor","values":[],"containers":[]}}}} Add to my Backpack

Sample Projects:    Whack an Alien!, Stamp and Swirl


How do I draw my own Actor?

Click on the Create Actor button, which is right next to the Add Actor button. Then use the drawing tools to create an Actor and save it.

Sample Projects:    Animate your own drawing