Kooldudese wrote:I have one last question, what im trying to do, is make the arrow (the actor that rotates) move to the enemy at the angle, but when i try it with "move to" it always moves to one exact location on the enemy, so if it was on the opposite side it would flip over to the spot... plz help me again, oh and thx again for earlier=)
ok .. this one comes in two parts
1. making the "arrow" go to the center of the player and not the same spot on the side..
Moveto uses the upper left corner as the coordinates. in otherwords the 0,0 of the sprite being moved is the upperleft corner
so the upperleft corner of the sprite is what will "touch" the center of the object being moved too. in this case because the canvas is partly empty, it makes it appear that the arrow is moving off to the side at same point each time.. when in fact the upperleft coner of the canvas is actually centered on the object being moved to.
to counteract this, in the move to, you need to "offset" the moving object (the canvas in this case) by half its width and height. you do this by by subtracting it from the x,y of the moveto command
an example:
MoveTo("player_canvas",-player_canvas.width/2,-player_canvas.height/2, 10.000000, "enemy", "");
2. you need to stop the "arrow" from turning once it hits the character because once it "centers", the angles all change.
to do this, I will only change the angle, 'if' the canvas if it is not touching the player... that way it stays at its last position after colliding
I used a global variable 'on_enemy' and set it to 1 on collision
then on the bitmap draw command set it so once 'on_enemy' is = 1, it no longer recalculates the angle..
if (on_enemy!=1) //global variable set to 1 if collide
{
ang=direction(enemy.x,enemy.y,x+width/2,y+height/2); //only recalc if 'on_enemy' is =0
}
I could have also stopped redrawing the arrow at this point , and just continued to move the canvas, but, because it is very slow to draw the arrows, when I stop drawing them everything suddenly speeds up.
see example code attached... use mouse button ( click on the arrow) to activate... I removed the cursor controls while making this so smiley no longer moves..
- bmpseek.zip
- ged and sample bitmap
- (17.89 KiB) Downloaded 206 times
NOTE: unless you have a very specific reason for using canvas drawing, you may want to consider other options, because canvas drawing can get very slow..
hope that helps
feral