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 / [SOLVED] sprites stopping at screen edge

Author
Message
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 17th Nov 2021 01:32 Edited at: 17th Nov 2021 01:44
i have a few sprites that are supposed to enter the screen from the right side. they seem to move right up to the boarder and cant get past it my code is pretty simple i think

Edit: turns out i had to add setviewoffset even though its at 0,0?

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Nov 2021 01:59 Edited at: 17th Nov 2021 02:01
Quote: "i had to add setviewoffset"

are you trying to use 2d physics with that code?

SetViewOffset() wrote: "Using this command will automatically disable the four physics walls surrounding the screen"
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 17th Nov 2021 02:02 Edited at: 17th Nov 2021 02:04
That sounds odd, the offset defaults to 0,0

but this:


says the sprite will only move to the right if its to the left of the barrier, when the barrier x and sprite x are the same it would stop

so:
Quote: " enter the screen from the right side. they seem to move right up to the boarder and cant get past it"


is exactly what I would expect that code to do

maybe post an image or something showing what you are trying to achieve and we can give some suggestions.

Edit: Actually a good point VN, are you using physics?
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 17th Nov 2021 02:47
yes i am using 2d physics nomad and partimecoder what they are supposed to do is enter from the right side of the screen and move left untill they reach the barrier
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 17th Nov 2021 02:49
ok, that makes sense, when you set the offset it disables the *walls"

you would usually call SetPhysicsWallBottom/Top/Left/Right according to your needs
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 17th Nov 2021 02:57
This post has been marked by the post author as the answer.


setphysicsdebugon() to see what is going on

Also just in case

SetPhysicsWallLeft( 0 )
SetPhysicsWallRight( 0 )
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 17th Nov 2021 03:12
Quote: "setphysicsdebugon() to see what is going on"

yes thank you that helped out a lot and i setphysicswallright(0) fixed my issue
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 17th Nov 2021 03:21
Quote: "fixed my issue"


Good, by default walls on physics are always set on.

What I do is set all the walls off then I make my own sprite walls with collision set to on for good reason.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Nov 2021 05:57
Quote: "set all the walls off"

and the easiest way to do that is SetViewOffset(0,0) - it's a handy side-effect of the command.

some follow-up for the OP,

you don't have absolute control over the default physics walls re: changing any of their parameters (friction, restitution, etc).

i really don't know why they're on by default; they're handy in the most rudimentary scenarios but, as GCH offers, most of us turn them off and make our own once we're ready to take more control.

Login to post a reply

Server time is: 2024-11-21 12:35:27
Your offset time is: 2024-11-21 12:35:27