I got velocity to work but still having problems with physics not working. If I set the wall to physicsOn 2, then I can push the wall around. Any other setting and I walk right through it.
Here is my character code
SMWI = loadimage ("walkingSwordMan.png") //SMWI swordManWalking Image
SMW = createSprite (SMWI)
setSpriteSize(SMW, 20, -1)
setSpritePosition (SMW, 50,60)
setSpriteDepth(SMW, 5)
setSpriteAnimation(SMW,96,96,64 )
setSpriteShape(SMW,3)
setSpritePhysicsOn(SMW, 3)
playSprite(SMW, 15,0,9,9)
stopSprite(SMW)
Here is the code for my wall
wall1 = CreateSprite ( wall1 )
SetSpriteSize ( wall1 , 20 , -1 )
setSpritePosition (wall1,50,50)
setSpriteDepth (wall1,5)
setSpriteShape(wall1, 2)
setSpritePhysicsOn (wall1, 3)
Here is the check to see which button is pushed
if ( getPointerPressed ()= 1)
dir = getSpriteHit (getPointerX (), getPointerY ())
if dir = bNorth
north()
elseif dir = bEast
east()
elseif dir = bSouth
south()
elseif dir = bWest
west()
elseif dir = bNW
NW()
elseif dir = bNE
NE()
elseif dir = bSW
SW()
elseif dir = bSE
SE()
remstart
elseif dir = bTurn
if n > 56
n = 1
endif
n = n + 7
playSprite(SMW, 15,0,n,n)
stopSprite(SMW)
remend
endif
Here is the new movement and animation code
function north()
SetSpritePhysicsVelocity(SMW,0,negY# )
playSprite (SMW, 15,1, 9,16)
newY#=negY#
do
if newY# < negY# + 10
newY# = newY# + .20
else
SetSpritePhysicsVelocity(SMW,0,0 )
stopSprite(SMW)
exit
endif
sync()
loop
endfunction
Two things. I am not sure how to stop the velocity so I set it to 0,0. Also I am not sure if the collision isn't picking up do to the loop I am running inside the function.