Position questions
by kupo · in Torque Game Builder · 03/23/2010 (5:28 pm) · 1 replies
Ok, I have a few questions I hope someone can help with.
I am creating a game that has a scrolling camera (ala Legend of Zelda 1) where the camera moves left/right or up/down depending on where you go out of the screen.
I have enemy 'nodes' or anchor points where I plan to spawn enemies from. I am trying to get the position of that node to spawn enemies from, but I can't seem to get it to spawn from the same point every time. I'm assuming this has something to do with the scrolling camera.
At first, I was just using .GetPosition() to set the position of a newly created object on the same spot. This doesn't seem to work so well. Is there any way to get the same position, every time? I've noticed setting the world limits was always an issue, because it returns an X/Y position that is not the true world position.
Any suggestions or help are greatly welcomed. My OnLevelLoaded is below.
thanks!
function EnemyNode::OnLevelLoaded(%this, %level){
// we need to get the dynamic fields from this node and set the necessary
// timers and info
%SpawnRate = %this.rate;
//echo(%SpawnRate);
//set the world position of the node to a dynamic field for later retrieval
%pos = %this.getPosition();
%this.pos = %pos;
//first, we need to set a timer for this spaw
%this.setTimerOn(%SpawnRate);
//set the nodes invisible
%this.setVisible(false);
}
I am creating a game that has a scrolling camera (ala Legend of Zelda 1) where the camera moves left/right or up/down depending on where you go out of the screen.
I have enemy 'nodes' or anchor points where I plan to spawn enemies from. I am trying to get the position of that node to spawn enemies from, but I can't seem to get it to spawn from the same point every time. I'm assuming this has something to do with the scrolling camera.
At first, I was just using .GetPosition() to set the position of a newly created object on the same spot. This doesn't seem to work so well. Is there any way to get the same position, every time? I've noticed setting the world limits was always an issue, because it returns an X/Y position that is not the true world position.
Any suggestions or help are greatly welcomed. My OnLevelLoaded is below.
thanks!
function EnemyNode::OnLevelLoaded(%this, %level){
// we need to get the dynamic fields from this node and set the necessary
// timers and info
%SpawnRate = %this.rate;
//echo(%SpawnRate);
//set the world position of the node to a dynamic field for later retrieval
%pos = %this.getPosition();
%this.pos = %pos;
//first, we need to set a timer for this spaw
%this.setTimerOn(%SpawnRate);
//set the nodes invisible
%this.setVisible(false);
}
About the author
Associate William Lee Sims
Machine Code Games
When you say "I can't seem to get it to spawn from the same point every time", how far is it off? A couple of pixels? Half a screen? I'm trying to get a sense of what the issue might be and if you can provide some more information about the problem, another reason for your error might appear.