About Monkey 2 › Forums › Monkey 2 Programming Help › Virtual Class Declaration errors
This topic contains 4 replies, has 4 voices, and was last updated by 
 Jesse
 2 years, 6 months ago.
- 
		AuthorPosts
 - 
		
			
				
October 16, 2016 at 7:52 pm #4455
Was just updating TimelineFX to work with 1.08 and getting an error in the c compiler “constructors cannot be declared virtual [-fpermissive]”. So what I was doing was putting Virtual after the class name which as a result is now complaining that the “New” method cannot be declared virtual (worked ok before). Is there something I can do to make the New method not virtual or will I have to just start putting virtual after individual methods instead?
This code replicates the error:
Monkey12345678910Class Test VirtualField test:IntMethod New()test = 1EndEndFunction Main()Local t:=New TestEndThanks!
October 16, 2016 at 8:46 pm #4456I must’ve broken something – will fix.
October 16, 2016 at 9:04 pm #4458Ok just committed a potential fix for this, although you’ll have to rebuildall or rebuildmx2cc.
October 20, 2016 at 7:59 pm #4548I have a similar problem. With v1.02 it compiled fine. Current version gives this error:
Super class ‘fanotmX2.cftTween.TweenEquationCall’ has no default constructor
If I add a New method to it, it still gives this error.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744namespace fantomX2.cftTween#Rem'This is a copy of the monkey sample script in bananas/skn3/tweening/tween.monkey#End'--------------------------------------------------------------------------------------------------'Tween module contents#rem monkeydoc @hidden#endConst PI := 3.14159265'---------------'base classes#rem monkeydoc @hidden#endClass TweenGlobal Linear:TweenEquationCall = New TweenEquationCallLinearGlobal Back:TweenEquation = New TweenEquationBackGlobal Bounce:TweenEquation = New TweenEquationBounceGlobal Circ:TweenEquation = New TweenEquationCircGlobal Cubic:TweenEquation = New TweenEquationCubicGlobal Elastic:TweenEquation = New TweenEquationElasticGlobal Expo:TweenEquation = New TweenEquationExpoGlobal Quad:TweenEquation = New TweenEquationQuadGlobal Quart:TweenEquation = New TweenEquationQuartGlobal Quint:TweenEquation = New TweenEquationQuintGlobal Sine:TweenEquation = New TweenEquationSineField equation:TweenEquationCallField start:FloatField change:FloatField current:FloatField isActive := FalseField isLooping := FalseField isYoYo := FalseField duration:IntField loopCount:IntField timeStart:IntField timeCurrent:IntField timePrevious:Int' --- constructors ---Method New(equation:TweenEquationCall,startValue:Float,endValue:Float,duration:Int)SetEquation(equation)SetDuration(duration)SetValue(startValue,endValue)End' --- private methods ---PrivateMethod UpdateValue()current = equation.Call(timeCurrent,start,change,duration)EndPublic' --- value methods ---Method Value:Float()Return currentEnd' --- setup methods methods ---Method SetEquation(equation:TweenEquationCall)Self.equation = equationEndMethod SetDuration(duration:Int)Self.duration = durationEndMethod SetValue(startValue:Float,endValue:Float)start = startValuechange = endValue - startValueEndMethod SetYoYo(flag:Bool)isYoYo = flagEndMethod SetLooping(flag:Bool)isLooping = flagEnd' --- control methods ---Method Start()' --- this will re-start the tween ---Rewind()isActive = TrueloopCount = 0EndMethod Stop()' --- stop the tween from updating ---isActive = FalseEndMethod Resume()' --- resume the tween from a paused state ---isActive = True'update the start timer!EndMethod Rewind()' --- put the tween at the start of its tween ---timeCurrent = 0timeStart = Millisecs()UpdateValue()EndMethod FastForward()' --- set the tween at the end ---timeCurrent = durationUpdateValue()Stop()EndMethod ContinueTo(endValue:Float,duration:Int=0)' --- change the end target for teh valuestart = currentSetValue(start,endValue)If isActive'isActive so need to continue operationIf duration = 0'no duration specified so use previous duration!Self.duration = duration - timeCurrentElse'override durationSelf.duration = durationEndiftimeStart = Millisecs()timeCurrent = 0If duration <= 0duration = 0Stop()EndifElseIf duration > 0 SetDuration(duration)Start()EndifEndMethod YoYo()ContinueTo(start)End' --- class methods ---Method Update()If isActive'update the current time!timePrevious = timeCurrentLocal time := Millisecs() - timeStartIf time > duration'time is beyond length of tweenIf isLooping Or isYoYo'increase the loop countloopCount += 1'look at yoyoing the valuesIf isYoYotimeCurrent = durationcurrent = start + changeIf isLooping Or loopCount <= 1ContinueTo(start,duration)ElseStop()EndifElse'wrap around the tween to the starttimeCurrent = 0'timeStart = Millisecs()EndifElse'set the tween to the endtimeCurrent = durationcurrent = start + changeStop()EndifElse If time < 0'time is before the start of the tweentimeCurrent = 0timeStart = Millisecs()UpdateValue()Else'time is within the tweentimeCurrent = timeUpdateValue()EndifEndifEndEnd#rem monkeydoc @hidden#endClass TweenEquation' --- really just a grouping class for user access ---Field EaseIn:TweenEquationCallField EaseOut:TweenEquationCallField EaseInOut:TweenEquationCallEnd#rem monkeydoc @hidden#endClass TweenEquationCall' --- base class to provide a call function pointer work around ---Method Call:Float(t:Float,b:Float,c:Float,d:Float) AbstractEnd'---------------'Linear#rem monkeydoc @hidden#endClass TweenEquationCallLinear Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideReturn c*t/d + bEndEnd'---------------'Sine#rem monkeydoc @hidden#endClass TweenEquationSine Extends TweenEquationMethod New()EaseIn = New TweenEquationCallSineEaseInEaseOut = New TweenEquationCallSineEaseOutEaseInOut = New TweenEquationCallSineEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallSineEaseIn Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Override'return -c * Cos(t / d * (PI / 2)) + c + bReturn -c * Cos((t / d * (PI / 2.0)) * 57.2957795) + c + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallSineEaseOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideReturn c * Sin((t/d * (PI/2.0)) * 57.2957795) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallSineEaseInOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideReturn -c/2.0 * (Cos((PI*t/d) * 57.2957795) - 1.0) + bEndEnd'---------------'Back#rem monkeydoc @hidden#endClass TweenEquationBack Extends TweenEquationMethod New()EaseIn = New TweenEquationCallBackEaseInEaseOut = New TweenEquationCallBackEaseOutEaseInOut = New TweenEquationCallBackEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallBackEaseIn Extends TweenEquationCallField s := 1.70158Method Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= dReturn c * t * t * ((s + 1.0) * t - s) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallBackEaseOut Extends TweenEquationCallField s := 1.70158Method Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet = t / d - 1.0Return c * (t * t * ((s + 1.0) * t + s) + 1.0) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallBackEaseInOut Extends TweenEquationCallField s := 1.70158Field s2:FloatMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overrides2 = st /= d / 2.0s2 *= 1.525If t < 1.0Return c / 2.0 * (t * t *((s2+1.0) * t - s2)) + bEndift -= 2.0Return c / 2.0 * (t * t * ((s2 + 1.0) * t + s2) + 2.0) + bEndEnd'---------------'Elastic#rem monkeydoc @hidden#endClass TweenEquationElastic Extends TweenEquationMethod New()EaseIn = New TweenEquationCallElasticEaseInEaseOut = New TweenEquationCallElasticEaseOutEaseInOut = New TweenEquationCallElasticEaseInOutEndEnd#rem monkeydoc @hidden#endclass TweenEquationCallElasticEaseIn Extends TweenEquationCallField p:FloatField a:FloatField s:FloatMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideIf t = 0.0 Return bt /= dIf t = 1.0 Return b+cp = d * 0.3a = cs = p / 4.0t -= 1.0Return -(a * Pow(2.0,10.0 * (t)) * Sin(((t * d - s) * (2.0 * PI) / p) * 57.2957795)) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallElasticEaseOut Extends TweenEquationCallField p:FloatField a:FloatField s:FloatMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideIf t = 0.0 Return bt /= dIf t = 1.0 Return b+cp = d * 0.3a = cs = p / 4.0Return (a * Pow(2.0,-10.0 * t) * Sin(((t * d - s) * (2.0 * PI) / p) * 57.2957795) + c + b)EndEnd#rem monkeydoc @hidden#endClass TweenEquationCallElasticEaseInOut Extends TweenEquationCallField p:FloatField a:FloatField s:FloatMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideIf t = 0.0 Return bt /= d / 2.0If t = 2.0 Return b+cp = d * (0.3 * 1.5)a = cs = p / 4.0If t < 1.0t -= 1.0Return -0.5 * (a * Pow(2.0,10.0 * t) * Sin(((t * d - s) * (2.0 * PI) / p) * 57.2957795)) + bEndift -= 1Return a * Pow(2.0,-10.0 * t) * Sin(((t * d - s) * (2.0 * PI) / p) * 57.2957795) * 0.5 + c + bEndEnd'---------------'Bounce#rem monkeydoc @hidden#endClass TweenEquationBounce Extends TweenEquationMethod New()EaseIn = New TweenEquationCallBounceEaseInEaseOut = New TweenEquationCallBounceEaseOutEaseInOut = New TweenEquationCallBounceEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallBounceEaseIn Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet = (d-t) / dIf t < 0.3636363Return c - (c * (7.5625 * t * t)) + bElse If t < 0.7272727t -= 0.5454545Return c - (c * (7.5625 * t * t + 0.75)) + bElse If t < 0.9090909t -= 0.8181818Return c - (c * (7.5625 * t * t + 0.9375)) + bElset -= 0.9636363Return c - (c * (7.5625 * t * t + 0.984375)) + bEndifEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallBounceEaseOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= dIf t < 0.3636363Return c *(7.5625 * t * t) + bElse If t < 0.7272727t -= 0.5454545Return c * (7.5625 * t * t + 0.75) + bElse If t < 0.9090909t -= 0.8181818Return c * (7.5625 * t * t + 0.9375) + bElset -= 0.9636363Return c * (7.5625 * t * t + 0.984375) + bEndifEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallBounceEaseInOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideIf t < d/2.0t = (d - t * 2.0) / dIf t < 0.3636363Return (c - (c * (7.5625 * t * t))) * 0.5 + bElse If t < 0.7272727t -= 0.5454545Return (c - (c * (7.5625 * t * t + 0.75))) * 0.5 + bElse If t < 0.9090909t -= 0.8181818Return (c - (c * (7.5625 * t * t + 0.9375))) * 0.5 + bElset -= 0.9636363Return (c - (c * (7.5625 * t * t + 0.984375))) * 0.5 + bEndifElset = (t * 2.0 - d) / dIf t < 0.3636363Return (c *(7.5625 * t * t)) * 0.5 + c * 0.5 + bElse If t < 0.7272727t -= 0.5454545Return (c * (7.5625 * t * t + 0.75)) * 0.5 + c * 0.5 + bElse If t < 0.9090909t -= 0.8181818Return (c * (7.5625 * t * t + 0.9375)) * 0.5 + c * 0.5 + bElset -= 0.9636363Return (c * (7.5625 * t * t + 0.984375)) * 0.5 + c * 0.5 + bEndifEndifEndEnd'---------------'Circ#rem monkeydoc @hidden#endClass TweenEquationCirc Extends TweenEquationMethod New()EaseIn = New TweenEquationCallCircEaseInEaseOut = New TweenEquationCallCircEaseOutEaseInOut = New TweenEquationCallCircEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallCircEaseIn Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= dReturn -c * (Sqrt(1.0 - t * t) - 1.0) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallCircEaseOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet = t / d - 1.0Return c * Sqrt(1.0 - t*t) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallCircEaseInOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= d / 2.0If t < 1.0 Return -c / 2.0 * (Sqrt(1.0 - t * t) - 1.0) + bt -= 2.0Return c / 2.0 * (Sqrt(1.0 - t * t) + 1.0) + bEndEnd'---------------'Cubic#rem monkeydoc @hidden#endClass TweenEquationCubic Extends TweenEquationMethod New()EaseIn = New TweenEquationCallCubicEaseInEaseOut = New TweenEquationCallCubicEaseOutEaseInOut = New TweenEquationCallCubicEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallCubicEaseIn Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= dReturn c * t * t * t + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallCubicEaseOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet = t / d - 1.0Return c * (t * t * t + 1.0) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallCubicEaseInOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= d / 2.0If t < 1 Return c / 2.0 * t * t * t + bt -= 2.0Return c / 2.0 *(t * t * t + 2.0) + bEndEnd'---------------'Expo#rem monkeydoc @hidden#endClass TweenEquationExpo Extends TweenEquationMethod New()EaseIn = New TweenEquationCallExpoEaseInEaseOut = New TweenEquationCallExpoEaseOutEaseInOut = New TweenEquationCallExpoEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallExpoEaseIn Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideIf t = 0 Return bReturn c * Pow(2.0,10.0 * (t / d - 1.0)) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallExpoEaseOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideIf t = d Return b + cReturn c * (-Pow(2.0,-10.0 * t / d) + 1.0) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallExpoEaseInOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) OverrideIf t =0.0 Return bIf t = d Return b + ct /= d / 2.0If t < 1.0 Return c / 2.0 * Pow(2.0,10.0 * (t - 1.0)) + bt -= 1.0Return c / 2.0 * (-Pow(2.0,-10.0 * t) + 2.0) + bEndEnd'---------------'Quad#rem monkeydoc @hidden#endClass TweenEquationQuad Extends TweenEquationMethod New()EaseIn = New TweenEquationCallQuadEaseInEaseOut = New TweenEquationCallQuadEaseOutEaseInOut = New TweenEquationCallQuadEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuadEaseIn Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= dReturn c * t * t + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuadEaseOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= dReturn -c * t * (t - 2.0) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuadEaseInOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= d / 2.0If t < 1.0 Return c / 2.0 * t * t + bt -= 1.0Return -c / 2.0 * (t * (t - 2.0) - 1.0) + bEndEnd'---------------'Quart#rem monkeydoc @hidden#endClass TweenEquationQuart Extends TweenEquationMethod New()EaseIn = New TweenEquationCallQuartEaseInEaseOut = New TweenEquationCallQuartEaseOutEaseInOut = New TweenEquationCallQuartEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuartEaseIn Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= dReturn c * t * t * t * t + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuartEaseOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet = t / d-1.0Return -c * (t * t * t * t - 1.0) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuartEaseInOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= d / 2.0If t < 1.0 Return c / 2.0 * t * t * t * t + bt -= 2.0Return -c / 2.0 * (t * t * t * t - 2.0) + bEndEnd'---------------'Quint#rem monkeydoc @hidden#endClass TweenEquationQuint Extends TweenEquationMethod New()EaseIn = New TweenEquationCallQuintEaseInEaseOut = New TweenEquationCallQuintEaseOutEaseInOut = New TweenEquationCallQuintEaseInOutEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuintEaseIn Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= dReturn c * t * t * t * t * t + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuintEaseOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet = t / d - 1.0Return c * (t * t * t * t * t + 1.0) + bEndEnd#rem monkeydoc @hidden#endClass TweenEquationCallQuintEaseInOut Extends TweenEquationCallMethod Call:Float(t:Float,b:Float,c:Float,d:Float) Overridet /= d / 2.0If t < 1.0 Return c / 2.0 * t * t * t * t * t + bt -= 2.0Return c / 2.0 * (t * t * t * t * t + 2.0) + bEndEndOctober 20, 2016 at 9:14 pm #4550You need a constructor in the “TweenEquationCallLinear”
thats the error I get when I try to check for errors. I added the “Method New()” and the error went away.
For safety purpose you should add a default constructor to all of your classes. if you don’t you might run into something similar when you try to implement something similar with other classes.
 - 
		AuthorPosts
 
You must be logged in to reply to this topic.