- Joined
- Dec 20, 2010
- Messages
- 76
I'm learning struct and this is my first attempt of using it.
In method "onLoop", the debug msg never displays anything. Why can't I get this.slidedunit nor the value of this.? What thing is wrong in the code?
JASS:
library SlideUnit
struct SlideUnit
readonly unit slidedunit
readonly real speed
readonly real targetx
readonly real targety
private timer ti = CreateTimer()
private static method onLoop takes nothing returns nothing
local thistype this
call BJDebugMsg(I2S(this))
call SetUnitPositionLoc( this.slidedunit, PolarProjectionBJ(GetUnitLoc(this.slidedunit), this.speed, GetUnitFacing(this.slidedunit)) )
call KillUnit(this.slidedunit)
endmethod
static method create takes unit u, location loc, real speed returns thistype
local thistype this = allocate()
set this.slidedunit = u
set this.speed = speed
set this.targetx = GetUnitX(u)
set this.targety = GetUnitY(u)
call TimerStart( ti, 0.03, true, function thistype.onLoop )
set ti = null
return this
endmethod
endstruct
endlibrary