#### Howdy, Stranger!

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

# How to make an actor disappear and re spawn when colliding with another actor?

Member, PRO Posts: 168

Hi everyone, just wanted some help with collisions, how would I make an actor disappear and respawn in a random place when colliding with another actor, like in the game snake. Also how would I make an actor (the snake) die when colliding into the wall. Thank you for any help.

• London, UK.Member Posts: 12,822
edited January 2015

First question:

When actor collides with XXX

Change position x to random (0,123)

Change position y to random (0,123)

. . . . . . . . . .

Second question:

What does 'die' mean in this context ?

• Member, PRO Posts: 168

@Socks said:
First question:

When actor collides with XXX

Change position x to random (0,123)

Change position y to random (0,123)

. . . . . . . . . .

Second question:

What does 'die' mean in this context ?

Like in the game snake, when the snake runs into the wall, it's game over, how would you do that?

• Member Posts: 279

IF attribute gameover = true

delete actor snake

change attribute snakeLength = 0

spawn actor snake at x =0, y= 0

change attribute gameover = false

have this in another actor, not the snake.

• London, UK.Member Posts: 12,822
edited January 2015

@Thor said:
Like in the game snake, when the snake runs into the wall, it's game over, how would you do that?

What happens when the game is over ?

• Member, PRO Posts: 168
edited January 2015

@Socks said:
What happens when the game is over ?

It will just say game over, and you will be able to restart.

• London, UK.Member Posts: 12,822

@Thor said:
It will just say game over, and you will be able to restart.

Rule:

When snake actor collides with wall actor:

Display text: 'Game Over'

• Member, PRO Posts: 168

@Socks said:
Display text: 'Game Over'

Hi Socks, how would I make the game stop when the actor collides with the wall? Thanks for the help.

• London, UK.Member Posts: 12,822
edited January 2015

@Thor said:
Hi Socks, how would I make the game stop when the actor collides with the wall? Thanks for the help.

What do you mean by 'stop' ? Do you mean the snake stops moving ?

All these things, 'die', 'stop', 'game over' are pretty arbitrary, they could mean anything, can you be more specific, are you able to say what actually happens . . . i.e: you go to the score page, the snake explodes, a 'restart' button pops up, you are taken to the main menu page, the scene fades to black . . . etc etc

?

• Member, PRO Posts: 168

@Socks said:
First question:

When actor collides with XXX

Change position x to random (0,123)

Change position y to random (0,123)

. . . . . . . . . .

Second question:

What does 'die' mean in this context ?

Hi Socks, going back to the first question would i need a table for this? Would it be possible if you could explain it in a bit more detail please?

• London, UK.Member Posts: 12,822

@Thor said:
Hi Socks, going back to the first question would i need a table for this? Would it be possible if you could explain it in a bit more detail please?

The GameSalad Cookbook covers all the basics, it'll give you a pretty good overview.