Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Gamma

How do I make the player stay in the same spot where I left off while then closing the browser and still being in that exact spot.

1 decade ago by alexandre

EDIT: code updated: 2012.10.28 7:53 PM

Periodically update storage with current player pos, e.g.,

// main.js

storage: new ig.Storage(),
positionSnapshotTimer: new ig.Timer(1),

loadLevel: function(data)
{
	this.parent(data);
	
	this.player = this.getEntitiesByType('EntityPlayer')[0];
	
	if (this.storage.get(playerPos))
		this.player.pos = ig.copy(playerPos);
},

update: function()
{
	this.parent();
	
	if (this.positionSnapshotTimer.delta() > 0)
	{
		this.storage.set('playerPos', this.player.pos);
		this.positionSnapshotTimer.reset();
	}

	...
}

1 decade ago by Gamma

Thank you so much for your help, I appreciate it greatly. There's one thing that happened, I got an error, (Uncaught SyntaxError: Unexpected identifier), and it pointed at "loadLevel: function(data)". Something about requiring a name..

1 decade ago by alexandre

Not sure why you'd get this, but I did spot a bug condition inside update and have updated the code. Try again and let me know on private channels if problem persists.

1 decade ago by Gamma

I think I figured it out, I had another function that was named "loadlLevel", but now I don't know what to do....

1 decade ago by Gamma

Extra: Ok, I'll put what happened on the private channel. Look for "ImpactStorage plugin problems cont.".
Page 1 of 1
« first « previous next › last »