PDA

View Full Version : Is there a way to rotate an object more smoothly than this?



albino_pygmy
08-15-2015, 05:12 AM
I'm trying to figure out if there's a way to tweak this code to make my wheel spin a little more smoothly, or if it's just my laptop not being able to handle the code? The code works, it's just really laggish for me and the wheel appears to be very jumpy. On the plus side, I do like how it will stay within one of three spots on a wedge, avoiding landing on a line. Is there a way to keep that functionality (landing in one of those three spots) but make the wheel actually look like it's spinning all the time, and not partially and choppy?



Sub RndSpin(oShp As Shape)i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
Set oShp = ActivePresentation.Slides(i).Shapes("WheelGroup")
t = Timer + (Rnd * 5) + 5
Do Until Timer > t
oShp.Rotation = oShp.Rotation + 5
DoEvents
Loop
End Sub

John Wilson
08-16-2015, 05:18 AM
Spins fairly smoothly on my laptop (but it is an i7)

However your code doesn't make much sense. You have references oshp as the shape clicked to start the macro and then re- referenced it

If you are clicking the shape that spins this is all you need


Sub RndSpin(oShp As Shape)
Dim t As Single
t = Timer + (Rnd * 5) + 5
Do Until Timer > t
oShp.Rotation = oShp.Rotation + 5
DoEvents
Loop
End Sub