GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Random movement within a 3rd of a scene

aquamonkeyaquamonkey Posts: 36Member, PRO

I'm trying to create an actor that comes into the scene from the right, then moves randomly within the last 3rd of the screen. The actor should not leave the boundaries of the last 3rd of the screen once it moves into the scene.

Comments

  • UtopianGamesUtopianGames Posts: 5,686Member
    edited March 2014

    @aquamonkey made a quick demo for you, its using screen size so will work in any project no matter what device you're working on.

    Hope it helps.

    Darren.

  • aquamonkeyaquamonkey Posts: 36Member, PRO

    Thanks @DeepBlueApps‌, I've been trying to breakdown what you did for what I need. I have a score up in the top right and a fire button on the bottom right of the screen. I want the actor to move within the last 3rd of the screen similar to how you have it but don't want the actor to go near the score or fire button. How would you control the vertical padding so the actor stays within, say a 60px padding all around, within the 3rd of the screen, in iPad landscape?

  • aquamonkeyaquamonkey Posts: 36Member, PRO

    Sorry, I figured this out. Don't know why it was not working when I switched to iPad resolution, but it's fine now. So, if you don't want the actor to touch the edges of the screen, I controlled it by changing the last 3 rules...self.Position.X > the number width that you want it to rebound back from the rightside, self.Position.Y < the number height that you want it to rebound from the bottom, and so on. Thanks @DeepBlueApps‌, I'm really learning a lot from you!

  • aquamonkeyaquamonkey Posts: 36Member, PRO

    @DeepBlueApps‌, I just noticed after previewing your demo for a few minutes, that the actor eventually jumps left (outside) of the right 3rd of the screen. Looking at your method, it looks like that shouldn't be happening, but I've seen it happen repeatedly during preview (just give it a few minutes and you should see). If you have a way to keep the actor completely contained within the right 3rd, I'm all ears!

Sign In or Register to comment.