I recycled a stack from a previous discussion in Games
Ignore the "Untested" part on the top right as it applies to linear animation. The button "NonLinearFrame" sizes will generate the frame sizes by measuring the width of graphics in group "SpriteAnimation"
Then the stack script handles the animation, by way of the "Animate", "Reverse" buttons or the "NLAScroll" scrollbar.
Code: Select all
on NonLinearSpriteSizeAnimation iNum
lock screen
--// frame sizes are width of sprite
put item iNum of field "NonLinearFrameSizes" into frameSize
put "Current Frame Size:" && frameSize into field "FrameSize"
--// add or subtract current size of frame to/from HScroll
if iNum > lastFrame then add frameSize to frameScroll
if iNum < lastFrame then subtract lastWidth from frameScroll
if iNum = 1 then
put 0 into frameScroll
put frameSize into lastWidth
end if
--// adjust hSCroll for the difference in frame sizes
if frameSize > lastWidth then subtract (framesize-lastWidth) from FrameScroll
if frameSize < lastWidth then add (lastWidth-frameSize) to FrameScroll
put "Current Frame Scroll" && frameScroll into field "frameScroll"
--// store current frame and size to compare next frame/size
put iNum into lastFrame
put frameSize into lastWidth
--// adjust scroll and width of group to animate
set the hscroll of group "spriteAnimation" to frameScroll
set the width of group "spriteAnimation" to frameSize
unlock screen
end NonLinearSpriteSizeAnimation
Be sure your animation group has 0 margin or it'll throw off the animation. I was fussing with graphics sizes for half hour bfore I realized the group margin property was giving me 4 pixels of grief.
Note the alernative method of measuring sprites sizes at the bottom of the stack, This could be expanded on with more little trangles and tracking their locations all at once like we did above with the rectangle graphics. With the key/pin method you can avoid grouping the original image and having to 'edit group' constantly to adjust your graphics top optain sprite sizes and then exiting the group edit to test the animation. Just have a keyframe editing panel and an animation panel with the same image, one full size, the other resized for animation.
Oh once you have the numbers in field "NonLinearFrameSizes" you can just adjust them individually to get better results. The values in the field are only derived the moment time the checkbox is set true.
seems to give best results with this zombie, but there's still a pixel or two overlap between frames. Frustrating.43,48,62,77,76,89
Probably a layout that shows each frame idividually in a line side by side with all frames as if they were individual images would be easier to edit than making an adjustment in one size, and then watching the animation to see what happened as a result. That would require multiple copies of the group to manipulate.
Have fun!