Sprite.Height and Sprite.ImageHeight not working properly?

Bugs will be moved here once resolved.

Post » Thu Apr 10, 2014 2:44 pm

Problem Description
After loading an external image into a sprite with the option set to resize the sprite to image size you cant get Sprite.Height and Sprite.ImageHeight.
When I output the Sprite.Height it always shows the default value of 177, but all loaded images have sizes of 100, 200 or more pixels.
When I output the Sprite.ImageHeight it always shows 100 even if the loaded image has 200 or more pixels (can't find the reason for this).

The images have this sizes: 1.jpg 100x100 pixel, 2.jpg 100x100 pixel, 3.jpg 100x200 pixel, 4.jpg was a huge screenshot to see if size changes.
The animated sprites seem to resize properly, the screenshot was not streched but Sprite.Height returns 177 (the default value of the TempSprite object placed outside of the layout).

Attach a Capx
Attached

Description of Capx
It loads a banner.txt file containing a list of filenames like 1.jpg|2.jpg|3.jpg... and then creates a loop to create a new sprite for each image.
To be able to position them depending on their height I used a second sprite object (TempSprite) to load the image first and then use Sprite.Height / Sprite.ImageHeight in the Create Sprite action. All Sprites should move from top to bottom with 10px space between them and wrap around at the end (wrap behavior does not seem to work properly if youc reate sprites outside of the layout so I used my own code with position check)

I installed XAMPP (local Apache Server) to test it on localhost. Don't know how to change it so you can reproduce it easily.
relevant code starts in line 19

Observed Result
Sprite.Height and Sprite.ImageHeigt of the TempSprite object is always the same value even if the loaded images have different sizes.

Expected Result
Since "Resize to Image Size" is set in the Load from URL action it should change the sprite size and the new size should be returned.

Affected Browsers
  • Chrome: YES
  • FireFox: Don't know
  • Internet Explorer: YES

Operating System and Service Pack
Windows 8.1 64 Bit

Construct 2 Version ID
r166
You do not have the required permissions to view the files attached to this post.
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
58
S
18
G
6
Posts: 756
Reputation: 9,591

Post » Tue Apr 15, 2014 2:51 pm

Closing as not a bug. Your events are wrong, you try to read the size before 'On image URL loaded' triggers.
Scirra Founder
B
402
S
238
G
89
Posts: 24,632
Reputation: 196,031

Post » Tue Apr 15, 2014 3:09 pm

But when I add a "On Image URL loaded" (triggers once after loading an image) event and set a variable containing Sprite.ImageHeight it returns 0. o.O
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
58
S
18
G
6
Posts: 756
Reputation: 9,591

Post » Tue Apr 15, 2014 3:13 pm

@Bl4ckSh33p - please submit a new report with a minimal .capx if you still have a problem (no disabled events, no unrelated objects, only a minimal reproduction of the issue). As it stands your existing report simply uses the wrong events.
Scirra Founder
B
402
S
238
G
89
Posts: 24,632
Reputation: 196,031

Post » Wed Apr 16, 2014 9:21 am

Hi. I tried to reproduce it in a new very simple project but it worked there.

I tried to add "On Image URL Loaded" to my existing code but it did not work with the For-loop (and you cant put it inside/below the loop) so I created this workaround and just changed the sprite size depending on the first letter in the filename (1 for 100 pixel, 2 for 200 pixel) and it seems to work now.
Image
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
58
S
18
G
6
Posts: 756
Reputation: 9,591


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest