Setting sub-sprite position on Parent Sprite with Sine Beh

For questions about using Classic.

Post » Wed Jun 22, 2011 11:12 am

To the point:
I have spaceship sprite (which moves and when not moving usies Sine Beh) which has couple of moving sub-sprites (panels, turrets, launchers etc) at i want them to "stick" to the image points of their destiny and mostly it works. But this is my problem - i want the sub-sprite to "float" with the parent sprite but also move having in mind the sine changing position. think about a hatch doors on side of spaceship that opens by sliding in a direction(being behind the ships) and i dont know how to set it. i want the "hatch" doors to slowly open and close when i order so but with sine beh in mind.

Ofcourse i can do the same by adding frames to the spirte but this seems more VRAM eating and less elegant (and mostly - needless)
B
16
S
5
G
4
Posts: 211
Reputation: 3,767

Post » Wed Jun 22, 2011 11:37 am

[code:6cwfrdso]clamp(lerp(door.x,ship.imagepointx("point"),1-0.5^timedelta),ship.imagepointx("point")-5,ship.imagepointx("point")+5)[/code:6cwfrdso]
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Jun 22, 2011 12:11 pm

Okeey... you want me to print it and stick on my fridge doors or something? :P
please make your answear a bit more explanatory, i am not a CC pro.
B
16
S
5
G
4
Posts: 211
Reputation: 3,767

Post » Wed Jun 22, 2011 12:29 pm

That would be the x of your door sprite, with a leeway of 5 pixels either way. You may need to adjust to how ever wide you want it to move. Then just set its y to ship.imagepointy("point").
I'm not too sure how well that will work with sine, so you may need to make a switch using pv's.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Jun 22, 2011 1:27 pm

i see. should i use this with "set positiom x/y" ?
what type of command to use?
B
16
S
5
G
4
Posts: 211
Reputation: 3,767

Post » Wed Jun 22, 2011 1:35 pm

Always set x/y would do it.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests