Hi All,
I have placed a VirtualJoystick in my Platform Test, I have managed to move my Pirate Sprite Left & Right with Animations, but how do I make him Jump UP to the next Platform.
Here is what I have so Far, also attached a pic.
+ Code Snippet// a virtual joystick
AddVirtualJoystick ( 1, 50, 270, 60 )
// our main loop
do
// obtain information about the accelerometer
x# = GetDirectionX ( )
y# = GetDirectionY ( )
// face the correct angle
angle# = ATanFullRad ( x1# - x#, y1# - y# )
SetSpriteAngle ( Pirate_Sprite, angle# )
//AS# = GetVirtualJoystickX( 1 )
//Print ( AS# )
// add accelerometer data to our sprites position
SetSpritePosition ( Pirate_Sprite, GetSpriteX ( Pirate_Sprite ) + x#, GetSpriteY ( Pirate_Sprite ) + y# )
// turn physics on
SetSpritePhysicsOn ( Pirate_Sprite, 2 )
SetSpritePhysicsOn ( Pipe1, 1 )
SetSpritePhysicsOn ( Pipe2, 1 )
// make sure sprite can't move past the left of the screen
// alter default gravity
SetPhysicsGravity ( 10, 10000 )
if ( GetSpriteX ( Pirate_Sprite ) < 10 )
SetSpriteX ( Pirate_Sprite, 10 )
endif
// make sure sprite can't move past the right of the screen
if ( GetSpriteX ( Pirate_Sprite ) > 660 )
SetSpriteX ( Pirate_Sprite, 660 )
endif
// make sure sprite can't move past the top of the screen
if ( GetSpriteY ( Pirate_Sprite ) < 10 )
SetSpriteY ( Pirate_Sprite, 10 )
endif
// make sure sprite can't move past the bottom of the screen
if (GetSpriteY( Pirate_Sprite ) > 230 )
//SetSpriteVisible ( Pirate_Sprite, 0 )
SetSpritePosition ( Pirate_Sprite, 310, 122 )
endif
// display instructions
//Print ( "Use the virtual joystick to" )
//Print ( "control the player" )
// get input from joystick
joystickX# = GetVirtualJoystickX ( 1 )
joystickY# = GetVirtualJoystickY ( 1 )
// find player position
x# = GetSpriteX ( Pirate_Sprite )
y# = GetSpriteY ( Pirate_Sprite )
// work out movement direction
x1# = x# - joystickX#
y1# = y# - joystickY#
// update player position
SetSpritePosition ( Pirate_Sprite, GetSpriteX ( Pirate_Sprite ) + ( joystickX# / 0.65 ), GetSpriteY ( Pirate_Sprite ) + ( joystickY# / 0.65 ) )
// scroll the screen
//SetViewOffset ( 0.0, y# - 50 )
AS# = GetVirtualJoystickX( 1 )
// when there is no input stop animation
if ( joystickX# = 0.0 and joystickY# = 0.0 )
StopSprite ( Pirate_Sprite )
SetSpriteFrame ( Pirate_Sprite, 1 )
endif
if AS# = -0.9
PlaySprite ( Pirate_Sprite, 10, 1, 1, 6 )
endif
if AS# = 0
PlaySprite ( Pirate_Sprite, 10, 1, 7, 12 )
endif
// update the screen
Sync()
loop
// Many Thanks
Many Thanks
[Mod Edit: Placed your code in a code box for you.]