Capturing last location's object in a variable?
<p>Right now I've got about a 10x10 grid of squares that the player can move 1 square at a time on.
When they hop to a square, I need an animation to play based on the sprite_index of the square they're jumping to and the one they just came from.
I've got the "jumping to" one sorted out.
in a collision event between the player and the square (other here being the square):</p>

<pre><code>with(other){
if sprite_index = sGreenH {
instance_create(x,y,oGreenPlayerAni)
</code></pre>

<p>(also is there a better way to do the above? instead of spawning it ontop of what's there can I delete it/replace it THEN put something?)</p>

<p>So now I'm trying to get an animation to play from the square the character is leaving. I can do that with the player collision w/ square :</p>

<pre><code>xx = xprevious and yy = yprevious 
instance_create(xx,yy, someanimation)
</code></pre>

<p>problem there is that I can't customize which animation plays. There are 4 possible colors of animations to use for 4 diff color squares.
so I tried with the collision event in my square with the player making a variable like</p>

<pre><code>if sprite_index = sGreen {
global.previousColor = 1
</code></pre>

<p>for each of my colors. and then in my player's collision event with the square again I have</p>

<pre><code>if global.previousColor = 1 {
instance_create(xx,yy, oGreenHollowAni)
</code></pre>

<p>And then I get an error when I move.</p>

<p>Code square colliding with player (player on a square) : <a href="http://puu.sh/n9zCY/2f226b6d3c.png" rel="nofollow">http://puu.sh/n9zCY/2f226b6d3c.png</a></p>

<p>Code player colliding with square : <a href="http://puu.sh/n9zK6/deac1a09f5.png" rel="nofollow">http://puu.sh/n9zK6/deac1a09f5.png</a></p>

<p>Error : <a href="http://puu.sh/n9zPj/ea84a9a943.png" rel="nofollow">http://puu.sh/n9zPj/ea84a9a943.png</a></p>