I'm doing a simple tilt (left-right) scroller game (something like Jetpack Joyride but vertical, like Off The Leash or Nimble Bit's Scoops) and I need "walls" on both sides of the screen.
Thing is, I'm using the Accelerometer object and adding/subtracting X pixels to reposition the player active object and the frame is set to auto-resize accordingly to the user's device (it has a 768x1136 frame, game is running with a 640x960 window size, that expands to the iphone 5 or ipad screens).
So I need the "walls" to stop the player from tilting out of the visible frame.
What would be the best way to do it right?
I tried a couple:
- (negate) object is # pixels from left/right frame -> the player will tilt to left/right, otherwise it shouldn't, right?
- used a hidden object on both sides that automatically position to the visible edge of the device - on overlapping the walls -> the tilting would stop
But neither way was foolproof, the last being the most annoying - sometimes if forcing the tilting, the player object would simply jump across the wall, and whenever it "stopped", it would kinda stick to the wall (moving to the other side had a certain delay, like something that was glued and got pulled off).
I remember back in the days that a simply bouncing object would bounce off a wall and that was it, but now using expressions with acceleration values I'm outta clue of how to do it properly...
Any ideas? Thanks in advance!!