@sleenee, no, you don't need different instances of the same level. See this guide:
1 decade ago
by RomainT
How do you place the hero at a given position ?
does the level load a fresh copy every time the player warps to a different screen?
If that's the case, we're gonna need some global variables to keep track. Or else the same monsters/powerups get generated every time we enter said screen.
1 decade ago
by sleenee
@stahlmanDesign
Ah i see, so you have another entity in place , the "warppoint" where your player spawns at levelload. And you probably enhanced the "levelchange" code with a variable that contains the designated warppoint.
Would you mind showing some code for this warppoint principle? Because now I just used the player entity itself and just put that in the map but that will just create 2 or more players in this case. :)
already a lot of thanks for the explanation you just gave.
I don't have it working in Impact yet. I haven't had time. I did it in another Objective-C project and the way I described it here is how I would do it if I did it all over again in Impact. If I get around to it, I'll share the code.
1 decade ago
by sleenee
i see,
well already a lot of thanks for sharing you know :), it's very helpfull
what you need are the levelchange and the void entitie out of the biolab entitie pack
the levelchange needs a slight adjustment
...
_wmDrawBox: true,
_wmBoxColor: 'rgba(0, 0, 255, 0.7)',
size: {x: 8, y: 8},
level: null,
spawn : "s0", // NAME OF THE VOID FOR THE POS
......
// CHANGE THE LOAD METHOD AND ATTACH THE CODE
ig.game.loadLevel( ig.global['Level'+levelName] );
if(this.spawn)
{
var spawnpoint = ig.game.getEntityByName(this.spawn);
if(spawnpoint)
{
ig.game.spawnEntity(EntityPlayer, spawnpoint.pos.x, spawnpoint.pos.y);
}
....
spawn takes the name of the void in the other level
to avoid a duplicated player spawing in the main level you probably want to load you player in the main.js
like that:
var spawnpoint = ig.game.getEntityByName("mainspawnpoint");
ig.game.spawnEntity(EntityPlayer, spawnpoint.pos.x, spawnpoint.pos.y);
Hi,
I'm having trouble getting my player to spawn at different coordinates based on the room he came from, despite trying to follow some of the tips from this thread. I'm using the levelchange.js and trigger.js entities. Here's what I've got.
main.js
currentLevel: null,
lastLevel: null,
init: function() {
this.loadLevel( LevelCave001 );
this.currentLevel = LevelCave001;
ig.game.spawnEntity( EntityPlayer, 802, 548 );
},
update: function() {
this.parent();
var player = this.getEntitiesByType( EntityPlayer )[0];
// screen follows player
if( player ) {
this.screen.x = player.pos.x - ig.system.width/2 + 18;
this.screen.y = player.pos.y - ig.system.height/2 + 30;
}
},
loadLevel: function( data ) {
this.parent( data );
if( this.currentLevel == LevelCave001 && this.lastLevel == LevelCave002 ) {
this.lastLevel = this.currentLevel;
this.currentLevel = LevelCave001;
ig.game.spawnEntity( EntityPlayer, 812, 932 );
}
else if( this.currentLevel == LevelCave002 && this.lastLevel == LevelCave001 ) {
this.lastLevel = this.currentLevel;
this.currentLevel = LevelCave002;
ig.game.spawnEntity( EntityPlayer, 942, 72 );
}
else if( this.currentLevel == LevelCave002 && this.lastLevel == LevelField001 ) {
this.lastLevel = this.currentLevel;
this.currentLevel = LevelCave002;
ig.game.spawnEntity( EntityPlayer, 1096, 2768 );
}
else if( this.currentLevel == LevelField001 && this.lastLevel == LevelCave002 ) {
this.lastLevel = this.currentLevel;
this.currentLevel = LevelField001;
ig.game.spawnEntity( EntityPlayer, 1038, 308 );
}
},
He always begins correctly-positioned in the first room. But upon changing rooms, the screen goes to the top-left corner of the map. I can't tell if the player's even been spawned or not.
Also I will probably need to kill the player off from the last room so there aren't two of them. Just not sure where or when to do this. Thanks in advance!
1 decade ago
by gashiss
Please could anyone post this kind of teleport exemple?
I am a bit confused working with this.
Thanks.
1 decade ago
by amadeus
I'm still very much an ImpactJS newbie, but I handled it by creating 2 types of entities.
1) a Goto entity, that when triggered takes the user to the defined level:
https://gist.github.com/45b2d972cce997023a0f
2) a StartFrom entity, that is used to start the character from that specified location when coming from defined previous map:
https://gist.github.com/966d6872b6c04e8779a5
I then have a special 'gotoLevel' function in my game that looks like this:
https://gist.github.com/721f7ee710b950a0d980 that can take the strings passed around and convert them into actual level names.
Basically it allows me to use the level editor to design my levels, my goto points, then I just add the gotoLevel variable to that instance to specify the level name, then I set my startFrom entities, and add the level property, which is the string corresponding from the level they started from.
I realize this is an old thread, but I figured I'd reboot it with my technique. Perhaps someone could offer improvements or find it useful.
Page 1 of 1
« first
« previous
next ›
last »