#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# spawn new ball

Posts: 45Member

How can I make it so that when my ball is moved off it's starting position, a new ball spawns.

Also how can I make my game so that gravity doesn't affect the ball until it is moved off the starting position.

Any help appreciated.

• Posts: 9,901Member
edited April 2016

Depends on your controls? How are you grabbing the ball. Can you slam dunk? Remember everything is logic with code. Things do what you tell it to do when. These two videos should give you some ideas.

As to your main questions an easy way would be to have an invisible actor where the ball starts. From that actor you can track and spawn a new ball.

So in invisable actor

Rule

When overlaps and collides with ball

In the otherwise section

Spawn ball

Position X 0 Position Y 0 related to actor.

• Posts: 45Member

@Lost_Oasis_Games said:
So in invisable actor

Rule

When overlaps and collides with ball

In the otherwise section

Spawn ball

Position X 0 Position Y 0 related to actor.

@Lost_Oasis_Games said:
Depends on your controls? How are you grabbing the ball. Can you slam dunk?

Yes you would be able to slam dunk by grabbing the ball. Does this information help in coming up with a solution for the ball to not move until it is flicked? (Gravity doesn't affect the ball until flicked for the first time) if you can help, pls reply

• Posts: 1,478Member, PRO

@wongj19 said:
Does this information help in coming up with a solution for the ball to not move until it is flicked? (Gravity doesn't affect the ball until flicked for the first time) if you can help, pls reply

@wongj19 Hey , I attached a demo not sure if this is what your looking for.

Hope it helps

• Posts: 2,784Member, Sous Chef, PRO

@Icebox -- great demo. You are on fire this week!

• Posts: 1,478Member, PRO

@RThurman Thanks !

• Posts: 45Member

@Icebox said:
@wongj19 Hey , I attached a demo not sure if this is what your looking for.

This is a really nice demo, but sadly I was looking more of a flick gesture to move the ball. If u have time could you please make another demo as this would really help me. Thanks

• Posts: 45Member

@Lost_Oasis_Games said:
So in invisable actor

Rule

When overlaps and collides with ball

In the otherwise section

Spawn ball

Position X 0 Position Y 0 related to actor.

I tried this but is just spawns 2 balls. It also lags the apps so that I can't flick the ball anymore. Is there another way to do this?

• Posts: 45Member
edited April 2016

This is what I'm doing at the moment. @Lost_Oasis_Games

• Posts: 9,901Member

. Also add a timer to the spawn, like after .5 or whatever pace of time you want. Set the spawn to 0x-0Y and relative to actor. Show me your flick rules.

• Posts: 9,901Member
edited April 2016

Try this. Here is a proper flick throw with a basic spawn mechanic.

• Posts: 9,901Member

• Posts: 45Member
edited April 2016

heres my coding for throwing the ball that I copied off youtube. Which way should I use yours or mine. @Lost_Oasis_Games

I also made my game so that if the ball bounces on the walls of the screen more than 6 times, the ball disappears. How can I make my counter different for every ball? Heres the coding that i have at the moment. (not very good as I made it myself)

• Posts: 9,901Member
edited April 2016

Okay so a counter for each ball should be done with a self attribute.

In prototype actor of ball make a self integer. Bounce_Count

Now just replace self.bounce_count with your game.ball bounce attribute in the code you showed.

Your code for throw looks fine other than you don't need to do those change attributes for touch X and Y. No need for those.

• London, UKPosts: 1,893Member

@IceBox @Lost_Oasis_Games can I ask what programs you use to capture your screen and save to gif please?

• Posts: 1,478Member, PRO
edited April 2016

@KevinCross i record a video with quicktime and type in google 'video to gif' and choose the first link . u upload the video on their site and it turns it to gif save it and upload it here. i dont know if its ok i put a direct link here

• London, UKPosts: 1,893Member

@Icebox said:
@KevinCross i record a video with quicktime and type in google 'video to gif' and choose the first link . u upload the video on their site and it turns it to gif save it and upload it here. i dont know if its ok i put a direct link here

Ok thanks. I thought there might have been a program that did it in one or two simple clips.

• London, UK.Posts: 12,820Member
edited April 2016