RPG Maker Forums

This is probably a dumb question but because the code looks solid I have no idea what it could be.

I have 2 sprites. After their y becomes 0 they refuse to move any further (works as long a their y-value is < 0). Changing the VELOCITY to 1 or greater fixes the problem. Why? Why does @bg1.y += 0.5 not work but @bg1.y += 1 does?

Note that bitmap.height and Graphics.height both equal 480.

Sample Code:

class Scrolling_BG_Vertical VELOCITY = 0.5 # BUG: any velocity < 1 will bug and will not move the sprite down after it reaches "bg1.y == 0" or "bg2.y == 0" #VELOCITY = 1 # <<< works #VELOCITY = 0.9 # <<< bugs def initialize(image) @bg1 = Sprite.new @bg1.bitmap = Cache.test(image) @bg1.x = 0 @bg1.y = 0 @bg1.z = 1 @bg2 = Sprite.new @bg2.bitmap = Cache.test(image) @bg2.x = 0 @bg2.y = -@bg2.bitmap.height @bg2.z = 1 end def update @bg1.y += VELOCITY @bg1.y = -@bg1.bitmap.height if @bg1.y == Graphics.height @bg2.y += VELOCITY @bg2.y = -@bg2.bitmap.height if @bg2.y == Graphics.height p 'just making sure that update is being called every frame' endend
Is the float being rounded down somewhere in the Sprite class?

Also:

Code:
p @bg1.y # => 0@bg1.y += 0.5p @bg1.y # => 0.... wut... still 0?

Latest Threads

Latest Profile Posts

Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

Forum statistics

Threads
105,992
Messages
1,018,189
Members
137,771
Latest member
evoque
Top