Strange % issue in GE

Non-platform specific questions.

Strange % issue in GE

Postby bamby1983 » Tue Mar 26, 2013 2:06 am

This works:
Code: Select all
if (frame%2==0)
    x+=1;



But GE does not allow this to execute and says it's an error:
Code: Select all
if (animpos%2==0)
    animpos+=1;


Would anyone know why?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Strange % issue in GE

Postby skydereign » Tue Mar 26, 2013 2:40 am

That's because % can only be used with integers, and oddly enough, animpos is not an integer. You can cast it to be one though, so putting (int) before it will make that line work.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Strange % issue in GE

Postby bamby1983 » Tue Mar 26, 2013 3:14 am

skydereign wrote:That's because % can only be used with integers, and oddly enough, animpos is not an integer. You can cast it to be one though, so putting (int) before it will make that line work.

Thanks Sky! You know everything about GE, don't you! :)

I thought animpos would have been an integer coz you can't have a fractional value of the animation position.
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Strange % issue in GE

Postby Hblade » Wed Mar 27, 2013 10:52 pm

Try adding an (int) just before anipmos (With the ( and ) )
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Strange % issue in GE

Postby bamby1983 » Thu Mar 28, 2013 4:23 am

Thanks hblade. +1 for you although sky answered this.
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron