Move() set x and y
I have been messing around with alternate ways to move my "bullet."
I have been using the move() function a little bit but I cannot get it accurate. PHP Code:
If I am using a move(), I should not be putting it in a timeOut. But I'm assuming that there is no way to set a specific x and y with move(). With that being said, I'm guessing I have to calculate how much the x and y need to be increased/decreased... Which I am not sure how to do.. straight to the point I want my NPC to move directly to this.newx, this.newy at a speed of 0.5; |
PHP Code:
|
Quote:
Please forgive me if this sounds like a dumb question.. But what is the point of putting temp? Couldn't you just put this.dy, this.dist... etc Keep in mind I don't know much about "temp" stuff |
Quote:
Using temp also guarantees the variable will be empty/0 and won't conflict with other parts of your script. Quick example: PHP Code:
|
^^ what he said, simplified, temp variables (values) exist primarily within the function they are specified (unless otherwise passed and named).
"this" variables are accessible throughout the script. "temp" variables are accessible through a function but discarded and not maintained in memory. they can still be passed to another function. |
All times are GMT +2. The time now is 04:00 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.