Stencyl 3.4.0 is now out. Get it now!

How to make an actor cleanly wrap around without teleporting?

haxorcat

  • *
  • Posts: 7
What I mean by the title is that I want to make it so an actor, when they go too far to the left (for example), they'll appear on the right. However, the only way I know how makes them look like they're teleporting/not having all visual parts of themselves on the screen. Picture example of what I what I want:


« Last Edit: September 09, 2017, 09:49:02 pm by haxorcat »


LIBERADO

  • *
  • Posts: 2332
<a href="http://static.stencyl.com/games/37482-0.swf" target="_blank" class="new_win">http://static.stencyl.com/games/37482-0.swf</a>

Add this code to your actor:
   
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

haxorcat

  • *
  • Posts: 7
EDIT: I have another problem with this now: how do I make it so it loops around in ALL directions (up, right, down, diagonals), not just if it goes too far to the left?

LIBERADO

  • *
  • Posts: 2332
I can give you the code, but you must keep in mind that when the actor is entering the screen, its collision shape will not work until the entire body of the actor has entered the screen. This also happens with the code I provided in my previous post. If it will not be a problem for you, let me know.

« Last Edit: September 10, 2017, 01:36:12 am by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

haxorcat

  • *
  • Posts: 7
It will be a problem, unfortunately :(

LIBERADO

  • *
  • Posts: 2332
Then, you have to use a more complex method as, for example, duplicate your actor, i.e. create two identical actors, so while one actor is leaving the screen, the other actor is entering on the opposite side of the screen. Or maybe duplicating only the collision shape. Not tested yet, but I think it could work.

« Last Edit: September 10, 2017, 01:27:18 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

LIBERADO

  • *
  • Posts: 2332
Tested now, and yes, definitely my idea of duplicating the collision shapes works for not rotating actors.
   
Use the arrow keys to move the square and push the circle:
   
           <a href="http://static.stencyl.com/games/37509-0.swf" target="_blank" class="new_win">http://static.stencyl.com/games/37509-0.swf</a>

Blocks to add/modify/remove actor collision shapes at runtime are really very useful in many situations.
(Thanks to Justin for adding them to the Stencyl Palette.)

« Last Edit: September 10, 2017, 08:31:46 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

fliberdoodle

  • Posts: 8
You can easily fix the non-collision issue by adding the "make [actor] always active"
This may not work, but I'd assume it would.