1 decade ago by madd4mon
Hello there,
I'm fairly new to Impact and I am working on my first game right now. There were a lot of questions at first but thanks to Google and this forum here I could answer most of them. Unfortunately, I am stumped now.
I am looking for a way to get an entity by its ID - and I haven't found a solution yet. Maybe you can help me?
More context: In the game, blocks are continually falling from the upper edge of the playing field. The player has to click on them, answer a question to make them disappear. There are three block sizes which I have defined in three entity files. The game spawns one of those three entities after a certain countdown.
The game checks over which one the player is hovering and executes a function. It's not working properly though. When I click on one block, another one disappears. That's why I want to get a certain element by ID.
Here's some code.
I'm fairly new to Impact and I am working on my first game right now. There were a lot of questions at first but thanks to Google and this forum here I could answer most of them. Unfortunately, I am stumped now.
I am looking for a way to get an entity by its ID - and I haven't found a solution yet. Maybe you can help me?
More context: In the game, blocks are continually falling from the upper edge of the playing field. The player has to click on them, answer a question to make them disappear. There are three block sizes which I have defined in three entity files. The game spawns one of those three entities after a certain countdown.
The game checks over which one the player is hovering and executes a function. It's not working properly though. When I click on one block, another one disappears. That's why I want to get a certain element by ID.
Here's some code.
kommentar: function(objekt) {
var Animation = function() {
animated = true;
var r = $.Deferred();
var AnimationTimer = new ig.Timer(1);
if (AnimationTimer.delta() < 0) {
objekt.currentAnim = objekt.anims.kill;
} else {
AnimationTimer.reset();
}
setTimeout(function() {
r.resolve();
},1000);
return r;
};
var Kill = function() {
objekt.kill();
animated = false;
}
Animation().done(Kill);
},
update: function() {
if (this.inFocus() == true && animated == false) {
this.currentAnim = this.anims.hover;
if (ig.input.pressed("leftButton")) {
startTime = startTime;
var zufall = Math.floor(Math.random()*ig.game.fragenkatalog1.length);
box(ig.game.fragenkatalog1[zufall].frage,ig.game.fragenkatalog1[zufall].antwort1,ig.game.fragenkatalog1[zufall].antwort2,ig.game.fragenkatalog1[zufall].antwort1Wert,ig.game.fragenkatalog1[zufall].antwort2Wert,ig.game.fragenkatalog1[zufall].antwort3,ig.game.fragenkatalog1[zufall].antwort3Wert,ig.game.fragenkatalog1[zufall].name); //Hier werden die Parameter für die Box an das äußere JS übergeben
//inFocus resetten
ig.input.mouse.x = 0;
ig.input.mouse.y = 0;
}
} else if (animated == false) {
this.currentAnim = this.anims.idle;
this.anims.kill.rewind();
}
if (antwortRichtig == true) {
this.kommentar(this);
antwortRichtig = false;
}
this.parent();
},
