Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Animation Problem

Author
Message
MonkeyTooth
7
Years of Service
User Offline
Joined: 12th Feb 2017
Location:
Posted: 12th Feb 2017 08:17
Hey! Great forum here.

I've been working with AGK2 for the past few weekends. It's my first time using a game engine other than a few lazy tutorials in Unity. I'm new to programming and all that it entails as well.

That said, I have been going crazy over the past few days trying to figure something out and I would love some help. I'm sure it's a simple fix, but my brain is going every which way and I'm about to lose it. ha

Overview: My character has a sword that I want to be able to swing both left and right (static and moving) with animations playing. I have the animations working fine only when the character is moving left and right, but I can't get them to function when the character is static on the screen.

I'll attach a screenshot and I'll attach some crappy code. I can post more information if needed.

Thanks for your time!

MonkeyTooth



//Sprite Velocity
SetSpritePhysicsVelocity ( 1 , GetVirtualJoystickX ( 1 ) * 650 ,
GetSpritePhysicsVelocityY ( 1 ) )

//Jumping
jump = GetVirtualButtonPressed ( 1 )

if jump > 0
SetSpritePhysicsVelocity ( 1 , GetSpritePhysicsVelocityX ( 1 ) , -jump * 1000 ) //500
endif

//Sword
Slice = GetVirtualButtonPressed ( 2 )
Position = GetVirtualJoystickX ( 1 )

if Slice <> 0 and Position > 0
PlaySprite ( 1 , 40 , 0 , 2 , 11 )
elseif Slice <> 0 and Position < 0
PlaySprite ( 1 , 40 , 0 , 12 , 21 )
endif

Attachments

Login to view attachments
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 12th Feb 2017 14:24
I think that position more or less that cause the problem. maybe can add if position=0?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Feb 2017 20:48
Awesome graphics btw. Great job
MonkeyTooth
7
Years of Service
User Offline
Joined: 12th Feb 2017
Location:
Posted: 13th Feb 2017 16:30
Thanks for the response, hoyoyo80! I had attempted that previously and almost got to where I needed to be, but I'm just shy of what I'm trying to achieve.

The following is what I have now:

//Sprite Velocity
SetSpritePhysicsVelocity ( 1 , GetVirtualJoystickX ( 1 ) * 650 ,
GetSpritePhysicsVelocityY ( 1 ) )

//Jumping
jump = GetVirtualButtonPressed ( 1 )

if jump > 0
SetSpritePhysicsVelocity ( 1 , GetSpritePhysicsVelocityX ( 1 ) , -jump * 1000 ) //500

endif

//Sword
Slice = GetVirtualButtonPressed ( 2 )
Position = GetVirtualJoystickX ( 1 )

if Slice <> 0 and Position > 0
PlaySprite ( 1 , 50 , 0 , 2 , 11 )
elseif Slice <> 0 and Position < 0
PlaySprite ( 1 , 50 , 0 , 12 , 21 )
elseif Slice = 1 and Position = 0
PlaySprite ( 1 , 50 , 0 , 2 , 11 )
endif


The character swings the blade just fine when static, but it's always to the right, even when the character is facing left. I've tried everything,, but it's just this one hump I can't get over for some reason. If you can give me any further help it would be much appreciated. Thanks again for your time!

Also, thanks for the compliment blink0k! I wasn't too sure about them.
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 13th Feb 2017 16:51
Maybe can add a state on which the sprite is currently facing?

spritefacing=1 //default 1, 1 is right and 2 is left

so when the directional button press,this spritefacing will change accordingly and add this factor to the slice direction. Sorry i use the word "maybe", quite new to AppGameKit

Login to post a reply

Server time is: 2024-11-22 02:30:50
Your offset time is: 2024-11-22 02:30:50