Interval and Speed blocks of a Sprite

According to Kodular docs:

  1. The Interval property of a sprite is after how many milliseconds its position is updated.

  2. The Speed property of a Sprite is the number of pixels it moves per interval.

My understanding of the above means an Interval of 100 and Speed of 100 means that the Sprite moves 100 pixels every 100 milliseconds (1/10th of a second). Therefore every second it moves 1000 pixels.

I have created the following blocks for my sprite

This means that every 10 milliseconds the Sprite should move 1/100th of the Canvas Height (1% of the height). After 1000 milliseconds (1second) it should move 100% of the Canvass Height.

However, it is taking 2 seconds to go from top to bottom. Why is this?

You may want to show your other blocks, though in them there could be the answer to your problem.


I have kept the app as simple as possible. There are no yellow or red warnings or errors.

When the Screen initialises it call Procedure InitialiseSprite. This procedure

  1. Disables the sprite
  2. Sets its height and width to 10% of screen width
  3. Sets its X position sightly right of the screen’s left edge of the screen.
  4. Sets Y position to 0 (top of screen)
  5. Sets Heading to 270 (straight down)
  6. Sets Interval to 10 so that Sprite’s position is updated every 10 milliseconds (the equivalent of 100 times per second)
  7. Set Speed to Canvas Height / 100 so that Sprite moves 1 /100th of the Canvas Height every 10 milliseconds (in other words the Sprite moves down 1% of the Canvas Height every 10 milliseconds)
  8. Enables the Sprite so it moves.

When Sprite reaches Bottom Edge it reverses direction straight up. When Sprite reaches Top Edge it reverses direction straight down. And so on.

Speed = 1% of Canvas Height.

Interval = 10 milliseconds = 100 times per second.

Therefore Sprite should move 100% of Canvas Height in 1 second.

Instead it takes 2 seconds from top to bottom and it takes 2 seconds from bottom to top. I have used used both Responsive and Fixed screen setting and it gives the same result.

I have tried on several different phones ranging from basic to mid level ones. Same result.

I’ve been googling this and it seems my calculations are correct. I also saw an article here that suggests canvas height and width are DP but sonus speed. Therefore speed is relative so again my calculations should be correct. Any advice @mika @Vishwas or anyone else?

In my game a block moves up and down and other blocks move left to right. I want the up and down movement to take 1 second, and the left to right movement to take one second.

I’ve managed to set the downward speed of the block so it’s relative to the speed of the left to right blocks. They all take 1 second. But the maths behind it still doesn’t work out.

The blocks Imposted above should see a full movement up to down take 1 second. However, I have to double the speed to achieve this. I can’t figure out why.


probably there is a timing issue? rather than calling the InitializeSprite procedure in the Screen.Initialize event call it a few milliseconds later using a clock component…
also maybe @Italo has an idea?


1 Like

The above blocks are just a simple example. In my actual game you have to set up speed, game type etc then the canvas becomes visible. I have a delay of 100 ms just to allow the various procedures to complete - I’ve tried with delays of up to 5000 ms but it still makes no difference. I’ve also put in delays before the sprites move to see if that helps but it doesn’t. I’m puzzled.

My experience is that the speed you give a sprite is not exactly what it is supposed to be relative to an actual clock. May be it will if you only have that sprite moving and nothing else is working in your app. But as you add more sprites and processes or calculations running while the sprite or sprites are moving, that time speed gets more and more inaccurate. I never made a game or app that needed exact timing in moving sprites, so I don’t really know how to work with that. Also you will have different times in different devices. I tested my games in many devices and I see the ball which should have a speed of 8 moving faster in a newer device while that same ball with the same speed 8 moving a little slower in a slower device. This shouldn’t be like that, but it is. It’s one of the many limitations you will find to make a game in Kodular or App Inventor.

Probably this is due to the fact that in the beginning this platform wasn’t built for complex game developing and it was more oriented to very basic sprite movement and teaching how it worked to students. Besides the canvas component is one of the less updated throughout the years, most likely because people don’t use it as much as the other components. I’m always pushing for a radical update of the canvas to keep up with the current Android capabilities. May be we will have a better canvas soon.


It’s quite annoying that this happens but I have set horizontal speed relative to vertical speed so in the end it works. It seems to be mostly fine across different phones but on lower end ones there is a noticeable but not game breaking delay.

1 Like

Glad that you found a workaround. If you don’t mind we would like to see a detail of what you did for reference when another user has your same issue.

All I did was set the sprite’s vertical speed to sprite’s horizontal speed x canvas height / canvas width

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.