-- This behavior cyclically skews a sprite when the sprite is rolled over. -- Works with any sprite that has a skew property. ------------------------- -- Ken Loge 05-06-2008 -- http://diginoodles.com ------------------------- property pActivateSkewEffect -- whether the sprite is skewing, or not property pSkewState -- the current state of sprite skewing property pSkewLimit -- a positive or negative integer defining the skew limit. property pSkewType -- "slant only" (default), or "full swing" property pSkewSpeed on beginSprite me pSkewState = #skewOver pActivateSkewEffect = FALSE end on getPropertyDescriptionList me list = [:] addProp list, #pSkewLimit, [#comment: "Skew limit:", #format: #integer, #default: 20, #range: [#min: 1, #max: 90]] addProp list, #pSkewSpeed, [#comment: "Skew speed:", #format: #integer, #default: 1, #range: [#min: 1, #max: 5]] addProp list, #pSkewType, [#comment: "Full swing skew:", #format: #boolean, #default: 0] return list end on exitFrame me skewSprite(me) end on mouseEnter me if pActivateSkewEffect = FALSE then pActivateSkewEffect = TRUE else pActivateSkewEffect = FALSE end if end on mouseLeave me if pActivateSkewEffect = FALSE then pActivateSkewEffect = TRUE else pActivateSkewEffect = FALSE -- reset sprite skew sprite(me.spriteNum).skew = 0 end if end -- cyclically skew a sprite using a simple state switcher on skewSprite me if pActivateSkewEffect = TRUE then if pSkewState = #skewOver then sprite(me.spriteNum).skew = sprite(me.spriteNum).skew + pSkewSpeed if sprite(me.spriteNum).skew > pSkewLimit then pSkewState = #skewBack end if if pSkewState = #skewBack then sprite(me.spriteNum).skew = sprite(me.spriteNum).skew - pSkewSpeed -- adjust for skew type case pSkewType of 0: skewVal = 0 -- slant only 1: skewVal = -pSkewLimit -- full swing end case if sprite(me.spriteNum).skew < skewVal then pSkewState = #skewOver end if end if end