This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-01-26 16:00:51

Nano511
Scratcher
Registered: 2011-01-20
Posts: 39

How do i make other sprites follow in the scrolling?

Okay, so here is what i need your guys help with.

I have a bar that scrolls, there are two total terrains for the bar. I need a red block to stay in one spot, but when the game starts that spot cannot be seen. To see it you have to scroll over to it.

I need help creating a code that will make the block stay in one spot.

If anyone wants to see what i have so far,

http://scratch.mit.edu/projects/Nano511/1558818

and for those who are interested in what i had originally,

http://scratch.mit.edu/projects/Nano511/1557608

Offline

 

#2 2011-01-26 16:25:44

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: How do i make other sprites follow in the scrolling?

You should be able to determine an offset by adjusting scollX so that the object (at x position 0) is where you want it on the terrain. Then you can use this script:

Code:

When green flag clicked
Forever
    Set x to ((the number you just found) * -1) + scrollX
    If x > -239 and x < 239
        Show
    Else
        Hide
    End If
End Forever

Last edited by Harakou (2011-01-26 16:26:04)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2011-01-26 17:21:29

Earthboundjeff
Scratcher
Registered: 2010-09-28
Posts: 1000+

Re: How do i make other sprites follow in the scrolling?


https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcR1SONrHUmdKZXQNDgtN_vpycOOo-BDMfnlqHZRA1lMpYXhX7Jc

Offline

 

#4 2011-01-26 18:56:43

Nano511
Scratcher
Registered: 2011-01-20
Posts: 39

Re: How do i make other sprites follow in the scrolling?

Harakou wrote:

You should be able to determine an offset by adjusting scollX so that the object (at x position 0) is where you want it on the terrain. Then you can use this script:

Code:

When green flag clicked
Forever
    Set x to ((the number you just found) * -1) + scrollX
    If x > -239 and x < 239
        Show
    Else
        Hide
    End If
End Forever

I dont really understand your first sentence. And could you explain the script better so i can adjust it to what i need?

Offline

 

#5 2011-01-28 17:03:29

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: How do i make other sprites follow in the scrolling?

Nano511 wrote:

Harakou wrote:

You should be able to determine an offset by adjusting scollX so that the object (at x position 0) is where you want it on the terrain. Then you can use this script:

Code:

When green flag clicked
Forever
    Set x to ((the number you just found) * -1) + scrollX
    If x > -239 and x < 239
        Show
    Else
        Hide
    End If
End Forever

I dont really understand your first sentence. And could you explain the script better so i can adjust it to what i need?

Sorry. Here's what you need to do:

1. Set the object's x position on the stage to 0. (So it is right in the middle of the screen)
2. Keep adjusting the scrollX variable until the terrain is lined up properly with the object. (For example, if you need to have you object on a chair, adjust scrollX until the object is at the same place as the chair.)
3. Now use the current scrollX value in the script I just gave you.

Hope that cleared things up.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer