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 / SetSpriteShapeBox Need Help

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 27th Jun 2016 15:41 Edited at: 27th Jun 2016 16:03
Hi.

I wrote this code for make custom shape for my characters.



so for one animation I need make larger shape when CharSelected = 6 and Player.state = 12 and back to first shape size when CharSelected is not equal to 6 and Player.state is not equal to 12 . so I wrote below code for do it, but it work for all CharSelected value.(e.g: CharSelected = 1, CharSelected = 2, .... CharSelected = 6) and even Player.state is not equal to 12.
all thing seem good but I don't know why work for all values.Can anyone help me to fix it?



Thanks.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 28th Jun 2016 05:23 Edited at: 28th Jun 2016 05:23
why do this happen?

even when I use SetSpriteShape(Player.spr,3), and change my animation to new frame, shape separated from character? I think shape should be stick to all frames. there is any way for fix this problem?



Thanks.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Jun 2016 08:55
The character in your animation frame is not centered in the same place as the previous frame?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 28th Jun 2016 09:04
Quote: "The character in your animation frame is not centered in the same place as the previous frame?"


Thanks for reply.

All frames are center before make sprite sheet.
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 28th Jun 2016 09:10
Unfortunately you'll have to call the SetSpriteShape command every single frame, every time the sprite changes frame. The collision box stays exactly the same shape and relative position and angle to the sprite object , not the actual image or frame the sprite is currently using. This is something I had to work around in my Santa Chimney Drop game. My character had two frames and I required him to have a polygon collision box. In one frame he was normal shape, I'd call the Set Shape command when he is created so he would collide with level objects correctly. Than when the frame changed to the character being flattened, I'd have to call the Set Shape command again so the collision box would also be a flattened shape. If I didn't do this, than my character would collide with objects where there is a blank space.

I hope that makes sense. Good luck!
My workstation was destroyed in a fire, help me out and get free media for AppGameKit and Game Guru: https://www.gofundme.com/bfpm0g
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 28th Jun 2016 09:38 Edited at: 28th Jun 2016 09:52
Thanks JLMoondog.

is your mean call SetSpriteShape(Player.spr,3) in loop for every thick?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 28th Jun 2016 11:51
I feel when Use SetspriteShape in loop, make FPS decrease to 57 or 58.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Jun 2016 12:44
If you set the sprite shape manually, it will be quicker. You can save the polygon coordinates in an array.
By automatically setting the shape, AppGameKit has lots of work to do.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Jun 2016 12:46
Maybe update it every 2, or three frames?

Maybe split the animation into a number of bones with collision on each? (Using spriter / boned. (or whetever it's called))
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 28th Jun 2016 16:29 Edited at: 29th Jun 2016 08:23
@Mobiius

Quote: "Maybe split the animation into a number of bones with collision on each? (Using spriter / boned. (or whetever it's called))"


I can't use bone because I made all animations without bone.

@BatVink

Quote: "If you set the sprite shape manually, it will be quicker. You can save the polygon coordinates in an array."


I set manually Polygon shape with SetSpriteShapePolygon() command according to baxslash method like below but it won't work currently in this project:



SetSpriteShape() command work very well for my characters but it make decrease frame.

is there any way for use SetSpriteShape() without decrease FPS?

at the first I should be fix this problem for continue make other parts on my game.
I thank the person who could help me.

EDIT: Really I don't know say this problem is a bug or not. because current shape should call in every frame for work correctly and when use it in loop, it make decrease FPS. also when I use SetSpriteShapeBox() command, it good not work correctly like SetSpriteShape() command in do--loop. please You be the judge.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Jun 2016 09:51
Baxslash gave an example, not a solution. You have to make it fit your sprite frames.
SetSpriteShape() is not designed to be called in-game. It is designed to create the best fit collision shape once, and it does this as designed, and very well. It's just like loading an image - you wouldn't do this every cycle of your game; you load it once.

You need to put the effort in to create the collision shapes per frame, save them in an array, and create a function that applies the shape for the frame you are currently displaying. This is normal development, and you shouldn't expect the core language to do this for you.
Once you have done it once, you can reuse the code in future games.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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: 29th Jun 2016 10:03 Edited at: 29th Jun 2016 10:37
Quote: "Baxslash gave an example, not a solution. You have to make it fit your sprite frames."


yes but I need soulution and don't know how can find this solution. I did everything that I knew and did not succeed.

Quote: "You need to put the effort in to create the collision shapes per frame, save them in an array, and create a function that applies the shape for the frame you are currently displaying."


I have 24 image and each image had about between 3 or 11 frames. I think your solution is not good batvink . your mean is I tried a couple of hours for each frame I create an shape?

if possible please give an example of your solution. because I do not know what's on your mind.

Thanks.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 29th Jun 2016 11:26
If you want perfect collision. you have to put in the effort.

You can't expect a programming language to do everything for you, if it does, you're moving more into a game engine, which may better suit your needs.

Programming language (e.g. AGK): code it all yourself.
Game engine (e.g. GameGuru): All coding done, just plug in your own data.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Jun 2016 11:45
Quote: "You can't expect a programming language to do everything for you."


it's not good answer Mobiius.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Jun 2016 12:11 Edited at: 29th Jun 2016 12:13
It's the perfect answer!
You need to learn how to code instead of asking everyone else to do it for you or asking for AppGameKit to be adapted to your needs!
AGK V2 user - Tier 1 (mostly)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Jun 2016 12:46
Quote: "It's the perfect answer!
You need to learn how to code instead of asking everyone else to do it for you or asking for AppGameKit to be adapted to your needs!"


Scraggle, I don't know why always disagree with everything you. Your letter reminds me of a cartoon Gulliver throws.

also I never said you or anyone write my code.

@BatVink

I need an little example for do this. and I can't find any example in AppGameKit for understand your mean.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Jun 2016 14:46
Quote: "I never said you or anyone write my code."

And your very next line is this:
Quote: "I need an little example for do this"


That is exactly what you're doing!
You can't be bothered working it out for yourself so you are asking other people to do it for you.
AGK V2 user - Tier 1 (mostly)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Jun 2016 15:08
Quote: "I need an little example for do this"


yes when you said me this problem is not bug and there is solution I need an example from you solution. because you said it's not a bug.

I wrote a fighting game and work very well and I wrote it myself and not others. but something like create basic shape in AppGameKit are Mockery and need example for better understand.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Jun 2016 15:09 Edited at: 29th Jun 2016 15:20
and do not have any evidence to prove that this is not an bug.

also there are many users that maybe had this problem and that were not yet encountered with it. so you can solve it forever.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 29th Jun 2016 15:36
I honestly don't know why you are bothering.
Quote: "I wrote a fighting game and work very well and I wrote it myself and not others"
Many of us here will remember many painful threads like: sprite flip problem (https://forum.thegamecreators.com/thread/216315), spritescale problem (https://forum.thegamecreators.com/thread/216752), Jump on Bullets (https://forum.thegamecreators.com/thread/216606 - which remarkably you resolved yourself but failed to share any insight with the community), Change Shape Angle (https://forum.thegamecreators.com/thread/216577) etc... To say "I wrote it myself and not others" is at best debateable, at worst an outright lie.

You're more like a community project leader, except you keep all the credit (and potential proceeds) for yourself.

In the words of Cersei Lannister:
Shame...
Shame...
Shame.



V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Jun 2016 16:13
Hey CJB,

I never say anyone help me to make a project.
in your 4 found threads,I just got a solution.

https://forum.thegamecreators.com/thread/216315

and in many other places you have to help me, so I can make a good game and I can not lie.

I think if you get the time for fix this solution, it's better than the discussion is inconclusive.

if developers try to fix user problems, really this community convert to Unity forum. mean before make a new threads, them can search in forum and find same problems. already I make a racing game with 3drad engine two years ago and currently I wrote 50% of this game with unity. because instead make threads and wait for answer, I searched in forum and find solution.
please think positive and not negative. when you help me, in fact you help to all users.

if Cersei Lannister say me shame, I'm not upset. But I've upset you, because I love you CJB and not Cersei.

Thanks.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Jun 2016 19:39 Edited at: 29th Jun 2016 19:41
I fix it with my script in first post (with little manipulated).

I hope if it work any where.

Thanks all for Guide.

Login to post a reply

Server time is: 2024-11-25 06:52:55
Your offset time is: 2024-11-25 06:52:55