actor magnetism and accelerometer angle

ID13ID13 Member Posts: 6
edited March 2012 in Working with GS (Mac)
Hi Folks,

First off I come from a design background so go easy on me regards my coding knowledge :)

So before I go to make my million dollar game...ahhemmm I wanted to learn a few basics, so with this in mind I plan on making an educational game. One of the core mechanics is getting a ball to rest on a hotspot (zone A). What I want to happen is if the accelerometer reaches a certain angle the ball will tip out of the hotspot zone.... see sketch below.

image

So from looking at @tshirtbooth tutorials and a few other templates this is what I have gathered so far…
1. I need to set up x and y attributes to track the ball’s position
2. I need to detect the hotspot and set a rule up in the ball code for that.
(Which I can do, but it does not look great as it snaps to the hotspot. )

What I want to do is…
1. When the ball reaches Zone B that it slows down slightly and if its velocity is too fast it would veer off in a new direction just like a golf ball hitting the rim of the hole.
2. If the ball is moving slow enough that it sits in Zone A unless hit by another object at a certain speed or that the iPad/iPhone it tilted up to much.

From what I have read I am thinking that the magnitude call is something I should use, just not 100% sure how to integrate it in….

If anyone could give me a few pointers just to get me started I would very much appreciate it.

Cheers All


Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You don't really need to track the ball's position. You can have an invisible actor (self.color.alpha=0) that sits in zone A and you can either have invisible actors in zone B and use collide rules for both zones or you can use magnitude on the ball's actor to determine the distance from zone A and then set the new direction and velocity. In Zone A's actor, you would have a rule that says if this actor collides with the ball actor, constrain game.ZoneAX (real) to self.position.X and constrain game.ZoneAY to self.position.Y. That way, if you have multiple Zone A actors, they only "activate" if the ball is touching them. And the ball is using the game.ZoneAX/Y attributes with the magnitude formula.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ID13ID13 Member Posts: 6
    Thanks @tatting will give it a go :)
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Or you could use < and > in your rules to customize by how many pixels you want things to happen.
  • wormilwormil Member Posts: 127
    I made a gravity field using the magnitude and some other fun math. It had the effect of bending a missile around a planet. If you are interested, I'll see if I can dig it up.
  • ID13ID13 Member Posts: 6
    I made a gravity field using the magnitude and some other fun math. It had the effect of bending a missile around a planet. If you are interested, I'll see if I can dig it up.

    Hi that would be really cool, I have been busy sorting art as I had come to this blocker. so any help would be great.
Sign In or Register to comment.