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.

AppGameKit Classic Chat / Change Shape Angle according to Sprite

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 23rd Feb 2016 17:00 Edited at: 23rd Feb 2016 17:10
Hi.

I added a Shape box with SetSpriteShapeBox() function for my character. but when character is dead , the shape box don't change angle with character.

for better understand I attached a Picture.



Thanks.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 23rd Feb 2016 17:10
The dead image is an animation of a guy falling over, the rotation of the sprite doesn't change, so the hit box doesn't rotate.

If you want to hit box to rotate, you'll have to rotate the actual sprite, rather than use an animation.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 23rd Feb 2016 18:34 Edited at: 23rd Feb 2016 19:15
Quote: "If you want to hit box to rotate, you'll have to rotate the actual sprite, rather than use an animation."


this is my sprite dead animation and use this code for rotate sprite but it always is zero.



CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 23rd Feb 2016 20:43 Edited at: 23rd Feb 2016 20:50
no words. almost...
Seriously Behdadsoft, are you a TGC mole planted in the forums to encourage discussion on really inane and simple issues?

Quote: "SetSpriteAngle(Enemy.spr,GetSpriteAngle(Enemy.spr)-180)"


You are flipping your shape upside down. That's what rotating something by 180 degrees does. Also, don't get the angle of the sprite and then modify it. Instead, use a float variable to store the angle and use that. IMO You are wasting valuable CPU time getting the angle.

PS... don't feel discouraged. Keep at it and you'll soon have something as good as "Street Karate Fighter"! In fact, why don't you rip off the graphics from an old 80s classic too? It worked for Gekko! You could do "Yie ar kung-po" or something

V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Feb 2016 07:47
Quote: "Seriously Behdadsoft, are you a TGC mole planted in the forums to encourage discussion on really inane and simple issues?"


Maybe.

when I decided convert my car game form 3drad to unity it take Two weeks, while when I used 3drad it take one year. reason in unity forum you can find any solution for your problem. while in TGC can't find good thing.

Quote: "
PS... don't feel discouraged. Keep at it and you'll soon have something as good as "Street Karate Fighter"! In fact, why don't you rip off the graphics from an old 80s classic too? It worked for Gekko! You could do "Yie ar kung-po" or something "




I made a fighting game better than "Yie ar kung-po". also I wrote some AI for enemy and work very well.
I know some question is very simple but sometimes easy is hard for someone. and really I learned more things about Programming in this forum.
in Physics mode there is no any problem but currently I used none Physics and I'm not familiar with this method.


I used angle# variable for change angle that work but my sprite don't playing.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Feb 2016 08:36
Quote: "reason in unity forum you can find any solution for your problem. while in TGC can't find good thing."


That's the reason why I, and probably several others, don't reply anymore.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Feb 2016 09:15
Quote: "That's the reason why I, and probably several others, don't reply anymore."


But I can't find anything about this problem in TGC forum.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 24th Feb 2016 09:25
Quote: "But I can't find anything about this problem in TGC forum."

It's a problem with the chair to keyboard interface.

Can you upload anim.png so if anyone wants to debug your code, they can?
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Feb 2016 09:25
Because it isn't a bug. The issue is your code.
For example check out these two lines...

if angle# <= 270
elseif angle# >= 270

The if will pass for both clauses if the value is 270 degrees (Which is wrong) so the sprite will never rotate.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Feb 2016 09:47
Quote: "It's a problem with the chair to keyboard interface.

Can you upload anim.png so if anyone wants to debug your code, they can?"


Quote: "Because it isn't a bug. The issue is your code. "


Yes I know.


also I attached anim16.png.

Attachments

Login to view attachments
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Feb 2016 15:32 Edited at: 24th Feb 2016 15:33
Quote: "
Mobiius
AGK Developer
Recently Online
Joined: 27th Feb 2003
Location: The Cold North
AGK Developer AppGameKit Bronze Backer
Posted: 23rd Feb 2016 16:10 Link
The dead image is an animation of a guy falling over, the rotation of the sprite doesn't change, so the hit box doesn't rotate.

If you want to hit box to rotate, you'll have to rotate the actual sprite, rather than use an animation.
"

Not that I'm repeating myself....



Change your animation so that he performs the animation, but doesn't fall down, rotate the sprite.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Feb 2016 15:42
Really I confused.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Feb 2016 15:50 Edited at: 24th Feb 2016 15:51
Your animation should be like this, rotate the sprite, not the animation.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Feb 2016 17:02 Edited at: 24th Feb 2016 17:03
It's really quite simple. The sprite shape only rotates if:
1-you rotate the sprite or...
2-you rotate the shape

If you do not rotate the sprite or the shape then the shape will not rotate.

Think of it like this:
your head is attached to your body
if you rotate your head then your head is rotated
if you rotate your body then your head is rotated
if you don't rotate your head or your body then your head does not rotate

Make sense?
Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Feb 2016 17:29 Edited at: 24th Feb 2016 17:40
Quote: "It's really quite simple. The sprite shape only rotates if:
1-you rotate the sprite or...
2-you rotate the shape

If you do not rotate the sprite or the shape then the shape will not rotate.

Think of it like this:
your head is attached to your body
if you rotate your head then your head is rotated
if you rotate your body then your head is rotated
if you don't rotate your head or your body then your head does not rotate"


Hi baxslash.

Yes I think understood. but when I used Mobiius Sprite Solution make exists another problem like below picture that the enemy sprite can't collide with ground and stay in air.



if used this code for rotate sprite:



I used this code for fix Player Position on the ground and I think problem is relate to it. before rotate sprite it worked very well but not now.




EDIT: How can Rotate Shape instead Sprite?
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 24th Feb 2016 22:48
Have you tried setting the sprite shape based on the sprite image at every frame? I don't know if that would work, but worth a try right? SetSpriteShape(spr,3) will automatically create a polygon shape to fit around the visible image. The CPU load will be huge, but it'll be a LOT easier to code for you.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 25th Feb 2016 06:50 Edited at: 25th Feb 2016 07:18
Quote: "Have you tried setting the sprite shape based on the sprite image at every frame? I don't know if that would work, but worth a try right? "


I don't know what is your mean.

Quote: "SetSpriteShape(spr,3) will automatically create a polygon shape to fit around the visible image. The CPU load will be huge, but it'll be a LOT easier to code for you."

yes , alreadey I used SetSpriteShape(spr,3) for create polygon Shape but result is like below picture:




I think in this section of my code there is an problem.


in this condition (if E_feetPos# >= GetSpriteY(ground)), E_feetPos# is less than GetSpriteY(ground) and should Eyspeed# = Eyspeed# + grav# move to down the player but don't do this happen.

whan I Print(E_feetPos#), it's value is 95 and GetSpriteY(ground) value is 97.5
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 25th Feb 2016 07:44
Quote: "I don't know what is your mean. "
Okay.
That shape is for a different frame of your animation. I was suggesting you try changing the shape at every frame of your animation.

Are you sure E_feetPos# = GetSpriteYByOffset(Enemy.spr) + (E_Heigh#/2.0) gives feet position if your character is lying down?

I suspect you want to influence the Y position with Eyvelocity# rather than set it to Eyvelocity# (i.e. add the velocity to the y position, don't set the y position to that value).


V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 25th Feb 2016 08:05 Edited at: 25th Feb 2016 08:09
Quote: "That shape is for a different frame of your animation. I was suggesting you try changing the shape at every frame of your animation."


id your mean I define SetSpriteShape() in do-loop?



if your answer is yes, I can't do it because i used this method for my duck shooter game and make drop frame in mobile devices.

Quote: "Are you sure E_feetPos# = GetSpriteYByOffset(Enemy.spr) + (E_Heigh#/2.0) gives feet position if your character is lying down?"


before use SetSpriteAngle() it worked very well, but currently don't Feet Position.

do you have better suggestionØŸ
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 25th Feb 2016 09:16
When I rotated your animation frames, I did it quickly, you need to position them in the correct place to match up with the collision box...

Plus there is far too much white space in the framesheet. trim it down as much as you can to save memory.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 25th Feb 2016 09:20
I thought that might be the case.
Quote: "The CPU load will be huge"



Quote: "do you have better suggestion"
Yes, but I can't repeat them here.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Feb 2016 12:15
Looks like we need another amazing baxslash tool to create editable bounding shapes for animated sprites... if only he had the time!
Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 25th Feb 2016 14:26
Quote: "Looks like we need another amazing baxslash tool to create editable bounding shapes for animated sprites... if only he had the time!"


it's good idea and I have time for it.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 25th Feb 2016 15:16
You're only using boxes for the shape anyway, so why not apply a new set of indices manually with SetSpriteShapePolygon at each frame? That shouldn't hit the CPU anywhere near as hard as getting AppGameKit to calculate the shape automatically for you.

V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 25th Feb 2016 16:22 Edited at: 25th Feb 2016 16:22
Quote: "why not apply a new set of indices manually with SetSpriteShapePolygon at each frame? "


Or...
Quote: "When I rotated your animation frames, I did it quickly, you need to position them in the correct place to match up with the collision box..."

Or just rearrange the images on the sheet so they fit within the collision box without any reorganizing of the collision box?
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 25th Feb 2016 16:42
Quote: "Or just rearrange the images on the sheet so they fit within the collision box without any reorganizing of the collision box?"
I did think about that, but it was such a painful experience trying to explain it last time that I didn't bother mentioning it. Lol.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th Feb 2016 09:08
I think if I keep repeating it, it'll suddenly make sense??

Typical English translations, if they don't understand, I'm not shouting loud enough!

Login to post a reply

Server time is: 2024-11-17 04:08:47
Your offset time is: 2024-11-17 04:08:47