Why is it that when the ball touches the goalie the backdrop(background) does not change to game over background? - background

Ball Movement Code:
Goalie Movement Code:
The code was working before, however it is not working now.
I tried to rework my code change my blocks for when the ball touches the goalie to send a message to the goalie and the goalie to send a message to change the backdrop(background) to game over backdrop.

According to the screenshots, it's possible you are not calling Ball Movement.
To improve your code, make it so that the soccer ball does not have the "When background switches to Game Over", since there is already a function in the same sprite that changes background.
Put the code in the ball sprite that is under "When background switches to Game Over " inside the "if touching goalie" statement.
100% Make sure you're calling ball movement in a forever loop under its own green flag clicked.

Related

How to move points of a CGPathRef

I am making a game where the player can draw a line with their finger, except I would like to show movement in the game. I have it so that when the player moves their finger it draws as if you were drawing on a piece of paper. However I want it to act more as if you were walking down a sidewalk and drawing side to side on it with a piece of chalk while moving. As the game goes on I would like the rest of the line to trail to the bottom of the screen while drawing. Thanks!

Test contact between 2 static physics bodies

My app has a set of horizonal bars (obstacles) that move up from the bottom of the screen. When they hit an invisible horizontal bar at the bottom 1/3rd of the screen, I want to spawn another set of obstacles.
I have set the spawning bar to be a gray rectangular sprite for now, just for debugging. When the obstacles move upwards, they simply pass under the spawning bar and no contact is detected. However, when I set the physicsBody.dynamic property of the spawning bar to "YES" the contact is detected. I can't use this, though, because it would push the bar offscreen.
Is there a problem with detecting contact between 2 non-dynamic bodies? How can I fix this?
Whoops, I upon further research, Sprite Kit doesn't check for contact between 2 static bodies. I had to set one of them to dynamic.

SKShapeNode with SKAction touch end when moves away from touch location

I'm currently making a very simple game to test out the Swift language from Apple, so far so good but I'm stuck with a touchesBegan and touchesEnded events while the SKShapeNode is animating away from the touch location.
The flow is this
Circles are animating around randomly
I touch one of them and it sets it to active
if the circle moves away from that touch it should become inactive
touchesEnded should fire as usual but also when the node moves away/out of the touch location
And I can't think of a way to do this, any help?
First of all, you have to include the code instead of just describing it.
An SKNode (or it's subclasses) do not lose a touch delegated to them even when it moves out of their apparent range. You will actually have to calculate the distance of the touch from the node's centre yourself in the -touchesMoved method and cancel the touch if it passes beyond a range you specify.

How do I trigger an event when a UIImageView reaches a certain location?

I have a UIImageView that moves around the screen, and I am trying to trigger a method when it is within a certain distance of another UIImageView, also moving. There is not necessarily any specific time I want to check, I want to know anytime it is within that distance. Help!
EDIT: I have multiple objects(the enemies) moving down the screen while the player is at the bottom of the screen. When the user taps the screen, it "shoots"(a new projectile object is created and the animation to move it up the screen is started). I am trying to detect when the "projectiles" hit the "enemies" and triggering an event(i.e. killing the enemy). I have no idea where to put the code to do this, or even what to do. Do I want to use the Notification System, or do I want to calculate if the projectile will hit the enemy as soon as it is fired?
You probably want to use Key-Value Observing. Here's an example.

How to make a scrolling background?

I'm making a Shooter game like "1943" and "Jamestown". I was wondering how I would make the scrolling background to simulate moving forward and How would I make this efficient? I was thinking about using a animated GIF or to make a looping BitMap. Please could someone help me out.
Thanks!
Take a look at the XNA framework for game development to develop a game that will use the computer's resources efficiently for smooth gameplay and frame rates. There are a number of books and online tutorials available.
If you're wanting a quick and dirty vertical background scroll in a windows form, you could always place a panel control inside another panel, set the outer panel to not display scrollbars, and make the inner panel twice as tall (or more), and set the background texture of the inner panel to be the background image you want to display. You can then animate the inner panel to move from top to bottom and reset back to the top when it reaches the bottom. Also be sure to design your background image so that the view at the top and the view at the bottom are the same for a smooth transition when the panel gets reset. You'll also want to call panel.Refresh() when you move the panel.
All that said, the XNA framework is really the way to go for game development.