Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [BUG] SetSpriteScale(spr,0.66,0.66) works, but SetSpriteScale(spr,2/3,2/3) not?

Author
Message
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 25th Sep 2016 16:55 Edited at: 25th Sep 2016 17:15
I don't understand the difference between 0.66 and 2/3
But if I am using 2/3 my Sprite is not shown on the screen.

img = LoadImage ... 1920 x 1080
spr = CreateSprite (img)

Virtual Resulution and WindowSize is 1280 x 720

Thanks for help.

works:



does not work



Don't get 0.666 from 2/3 in a value.



---- Can't edit the title, but Float is broken in my AGK2 version I think

w#, w, wf as float are all 0.000 or 0

w# = 2.0 / 3.0 works, but how could I get two Integers to a float and why do I have to? Okay, I can do the following: Integer / Integer * 1.0 to get it cast to a float


Solution?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Sep 2016 21:14 Edited at: 25th Sep 2016 21:14
When you divide 2 integers, you get an integer result, even if you save it in a float. Try:

w# = 2 / 3.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 27th Sep 2016 08:13
@BatVink,

the problem here is, that I get sometimes only integers. So how would I cast integers to real-float. 1920 / 1280 are both integers. Maybe I have to be careful with integers and dividing
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Sep 2016 08:47
Integers in float variables are fine. For example, this works:



Your solution earlier is a good generic way to deal with all scenarios, multiplying by 1.0:

Quote: "I can do the following: Integer / Integer * 1.0 to get it cast to a float"

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 28th Sep 2016 17:12 Edited at: 28th Sep 2016 17:14
2.0/3.0 would work

I think you can also do 2/3*1.0, or perhaps you need to do (2*1.0) / (3*1.0).

Login to post a reply

Server time is: 2024-11-25 02:08:21
Your offset time is: 2024-11-25 02:08:21