Width/Height Sprite Help

var sprite = createSprite(200, 300, 100, 50);

Why does this not change my sprites width and height?

Why do I have to use

Thank you! :slight_smile:

Hi, @melodi_kunn,

Can you share a link to a project we could look at to help you debug?

I made a very simple project with your code and it seems to be accepting the height and width.

Let us know and we’d be happy to help!



This is just a simple example. Do you think it has anything to do with the level they are on? Unit 3, level 9? Like for instance, certain code is not accessible until it has been introduced by the program?

Thank you!

Now that I looked at your example, I did see a few things … I remixed it and here is my remixed version…

I’m not sure why your 1st car size doesn’t change when you add the width and height component, but normally, you will declare a sprite without a width and height and it will use the width and height of the sprite itself (from the animation tab). Then, although you can use height and width to adjust the size, you will usually use the scale block (see my example) to adjust the entire sprite as a percentage of its original size (such as my .75 (75%)). You could also set the scale to be 1.5 (150%) of the original size, etc.

Also, in your example, both of your sprites had the same name (car). This could have been part of the problem because when you name two sprites with the same name and then you try to change attributes, the program will only remember the last one you named, so the first one may behave differently than you would expect. So, again, notice in my example that I named the 2nd one car2.

Although this may not definitively answer your original question, I hope it at least shows you a different way to approach it …

Let us know if you still have questions and we are happy to look at it.