Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » 2 axis scroller help
- Griftor05
- Scratcher
13 posts
2 axis scroller help
In a scroller, you should be able to create a moving object. In a two dimensional scroller, this would be a goomba, or a turtle or something. In pokemon, one of those trainers that moves back and forth. Either way, I can't seem to be able to figure out how to do something like that. I tried to make it glide to a specific location in relation to the player. Look here: http://scratch.mit.edu/projects/16010053/
Seems to work fine, right? Well, walk to the right, then walk to the left. See a difference in where the black ball goes?
Seems to work fine, right? Well, walk to the right, then walk to the left. See a difference in where the black ball goes?
- AonymousGuy
- Scratcher
1000+ posts
2 axis scroller help
This actually works correctly. The problem is it glides 1 seconds to the X, Y, but if you change the X, then it is supposed to glide to the new value, but is instead gliding to the old value.
- AtomicBawm3
- Scratcher
29 posts
2 axis scroller help
@AwesomeGuy is right. You cannot use the glide block here because it takes the values and then does the gliding, it does not continuously watch the values. Instead, what you need to do is something like this:
Where mX and mY are “for this sprite only”. You might have to tweak the repeat loops, but this should give you the result you're looking for.
when green flag clicked
forever
go to x: ((X) + (mX)) y: ((Y)+(mY))
end
when green flag clicked
set [mX v] to [-100]
forever
repeat (50)
change [mX v] by (4)
end
repeat (50)
change [mX v] by (-4)
end
end
Where mX and mY are “for this sprite only”. You might have to tweak the repeat loops, but this should give you the result you're looking for.
- AonymousGuy
- Scratcher
1000+ posts
2 axis scroller help
My name is AonymousGuy. @AwesomeGuy is right. You cannot use the glide block here because it takes the values and then does the gliding, it does not continuously watch the values. Instead, what you need to do is something like this:when green flag clicked
forever
go to x: ((X) + (mX)) y: ((Y)+(mY))
endwhen green flag clicked
set [mX v] to [-100]
forever
repeat (50)
change [mX v] by (4)
end
repeat (50)
change [mX v] by (-4)
end
end
Where mX and mY are “for this sprite only”. You might have to tweak the repeat loops, but this should give you the result you're looking for.
And also, I think the loop values should be 25.
- Griftor05
- Scratcher
13 posts
2 axis scroller help
Oh yeah! That makes alot of sense. Thanks.
And as I'm reading that, that sounds sarcastic.
It's not though. Thanks again
And as I'm reading that, that sounds sarcastic.
It's not though. Thanks again
- Discussion Forums
- » Help with Scripts
- » 2 axis scroller help