How to access assets from two colliding actors?

Game Editor comments and discussion.

How to access assets from two colliding actors?

Postby waggle » Sat Aug 26, 2006 4:31 pm

I have a situation were I have two colliding bodies and I need to create another based upon that collision.

Creating a new actor is simple using something like the below code:


CreateActor("MyActor", "MyActor", "view", "(none)", x, y, false);

The difficultly I am encountering is that I need to be able to access some of the variables in the newly made actor based upon the data from the two colliding actors.

In other words, in the collision event handling script I need to:

1. Create a new actor.
2. modify some of it’s actor variable contents based upon values from the two colliding actor’s variables.


How do I reference these variables?

Hopefully I’ve made myself clear.
waggle
 
Posts: 14
Joined: Sat Jul 29, 2006 8:59 pm
Score: 0 Give a positive score

Postby makslane » Sat Aug 26, 2006 5:52 pm

You can get the returned pointer to access the new actor:

Code: Select all
Actor *newActor = CreateActor("MyActor", "MyActor", "view", "(none)", x, y, false);

newActor->lives = 3; //For example
 


If you are in a Collision event, just use the actor 'collide' the access the variables on collide actor:

Code: Select all
newActor->lives = collide.lives; //For example
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby waggle » Sat Aug 26, 2006 8:06 pm

Excellent. Thanks for the assistance.
waggle
 
Posts: 14
Joined: Sat Jul 29, 2006 8:59 pm
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron