im making scrolling objects with the mouse when dragging the objects vertically.
When i scroll to the bottom my code WORKS i can make the objects do an infinite vertical scrolling.
BUT if i try to use the sames values and invert for scrolling to the top, nothing works, my objects stop scrolling !
I CAN'T use the two functions move up & bottom freely at the same time, it only work if i deactivate one of the two groups but i need the two functions working.
Can someone help???
here my 3 objects and my code
I don't really understand your code, but I think events from both groups are triggering at the same time and messing things up. You need to activate/deactivate groups, making sure that only one group is active at a time. When scrolling up - activate first group, deactivate the second. When scrolling down - deactivate first group, activate the second.
Hello Thanks dop2000 i tried that, but it's not working, youre right the triggering at the same time and i don't know how to solve that.
what i try to achive is create an loop scrolling sprites controled with mouse or touch
For example i have sprites 1-2-3, when sprite one leave the screen from bottom then he is replace on the top outside the layout after layer 3
if sprite 1 leave from top then he is replace at the bottom outside the layout after sprite 3
What im trying to achieve is this kind of scrolling effect for my sprites
You can easily do this with lerp.
To scroll up - set variable targetY to sprite.Y-500
To scroll down - set variable targetY to sprite.Y+500
On every tick: set Sprite Y to lerp(self.Y, targetY, dt*8)
thanks dop2000, i was sure my code was completely wrong, too messy and complex :D, im going to try your method :D
i tried but it's not working well
My sprite has a drag & drop behavior because i want the object to scroll vertically when dragged, i also added wrap behavior, but with this code the object doesn't leave the screen
Your events 2 and 3 are the same, they are probably triggered both at the same time and SCROLL_Y variable doesn't change because you subtract 500 and then add 500.
Thanks dop2000 i changed my code by this
It works but the object doesn't have a moving speed when i drag the object and then release, and when the object enter & leave the screen (wrap behavior doesn't work in this case i don't know why!!! )
Wrap function is not working !!!!
Here my sprite with wrap and my code
I'm telling you again - your conditions in events 2 and 3 are the same! It means that when you do the hold gesture over L1, both events are triggered.
And also, why did you put dt*-1 in lerp? Your sprite will move in the opposite direction! The third parameter in lerp function here is the speed. "dt" is the duration of one tick, if you want your sprite to move slower, change it to dt*0.5, or dt*0.1, but don't use zero or negative values!
It looks like you are changing things randomly hoping it will start working miraculously. Don't do this. Remove everything else except event #1 from your code, set SCROLL_Y variable to 1000 and see how it works. And then move from there.
Develop games in your browser. Powerful, performant & highly capable.
Thanks a lot dop2000 for your great explanations & help, so i removed everything no i set:
every-tick -> system set variable SCROLL_y to 1000
the problem i get is, i get some gaps between my sprites(empty spaces) when i drag the objects vertically some spaces appear.
Here you can see the space and also objects overlapped
Why do you set SCROLL_Y on every tick?...
You need to post your capx and detailed explanations of how it's supposed to work. I have no idea of what's going on on your screenshots.
Hi, thanks what i need to achieve is this effect
you see the scrolling controlled object moving vertically thats the only thing i need! :D
Thanks dop2000 but how to control the dragging of the object sprite with the mouse instead of a bouton click??