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 / Handling physics with fixtoScreen sprites

Author
Message
gsdblack
12
Years of Service
User Offline
Joined: 6th Dec 2011
Location:
Posted: 28th Feb 2012 05:40
I making a side-scrolling game where i want to detect collision only around the players feet(think streets of rage). I used setspriteshapecircle to set a circle around the feet but doesn't stay in place once i move the character. The tutorial says "You should not use physics or collision commands on sprites fixed to the screen as their debug shapes will not line up and they will interfere with physics sprites not fixed to the screen. " so what should I use?

[//player
seanImage = agk::LoadImage("Cake/cakewalk.png");
seanSprite = agk::CreateSprite(seanImage);
agk::SetSpritePosition(seanSprite, 20.0f, 70.0f);
agk::SetSpriteAnimation(seanSprite, 26, 36, 4);
agk::SetSpriteSize(seanSprite, 15.0f, -1);
agk::SetSpriteVisible(seanSprite, 0);
//agk::SetSpritePhysicsOn ( seanSprite, 2 );
//agk::SetSpriteShape(seanSprite, 3);
agk::FixSpriteToScreen (seanSprite, 1 );
agk::SetSpriteShapeCircle(seanSprite, agk::ScreenToWorldX(agk::GetSpriteX(seanSprite)), agk::ScreenToWorldY( agk::GetSpriteY(seanSprite)) , 30);]
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Feb 2012 09:00
Just don't use the fixToScreen command... this positions the visible sprite at a point relative to the screen and not the "world". Take a look at this tutorial, it explains the difference between the "World" and the "screen":
AGK Bitesize 001

Login to post a reply

Server time is: 2024-11-23 05:03:32
Your offset time is: 2024-11-23 05:03:32