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 / physics & setviewoffset

Author
Message
gsdblack
12
Years of Service
User Offline
Joined: 6th Dec 2011
Location:
Posted: 29th Oct 2012 16:52
I am making a constant side scroll game. Where the character will be in same x value you whole game but with the ability to jump. I tried move the player with setspriteX(getspritex + 0.25f) but these function don't work with the physics engine.

I was thinking about using the physics provided by box2d for jumping but when you change the viewoffset I know that messes up the physic borders/engine. So here is my questions...

How do I scroll the player since setspritex messes up the with physic engine? should i use velocity to constantly push it forward?

or should I not use box2d and create my own simple gravity effects.

I cant post the code right because I'm at work and I will be off around 4:30 cental. For now I can try give you my pseudo code from memory.



ps it just occured to me that I could use setphysicsgravity(10,10) to push player forward, would that work?
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 30th Oct 2012 00:08
You could always make your own dummy sprites for the screen borders.

Simply make them static and follow the view offset so will you get an moving border.

I use impulse in my platformer to move the player.

SetSpritePhysicsImpulse( Player.ID,Player.X, Player.Y,xForce#,yForce# )

Box 2d works great but neads some work to get right.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
gsdblack
12
Years of Service
User Offline
Joined: 6th Dec 2011
Location:
Posted: 30th Oct 2012 01:35
Thanks. is there a way to see the dummy sprite using agk::SetPhysicsDebugOn()? I created some dummy sprites but idk if it worked.
gsdblack
12
Years of Service
User Offline
Joined: 6th Dec 2011
Location:
Posted: 30th Oct 2012 03:07
my code
gsdblack
12
Years of Service
User Offline
Joined: 6th Dec 2011
Location:
Posted: 30th Oct 2012 03:56
project updated. unzip folder and run the game.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-28 09:12:35
Your offset time is: 2024-04-28 09:12:35