Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Creating @2x graphics with Spine
Started by alan73 May 29 2013 04:51 AM

7 replies to this topic
dynamic images @2x
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

alan73

[GLOBAL: userInfoPane.html]
alan73
  • Observer

  • 14 posts
  • Corona SDK

Just wondering how one goes around catering for this with Spine. Previously when doing animation or graphics I would have 2 versions, the normal and the @2x. Then setting up the config file to detect depending on the resolution of the device which one to use.

 

Is it possible to create two versions of your skeleton and images in Spine and then have it use the @2x version the same as you would with standard images? If so how do you do it, how do you adjust the scale and images and how do you reference the @2x version then.

 

Thanks



[TOPIC: post.html]
#2

chevol

[GLOBAL: userInfoPane.html]
chevol
  • Contributor

  • 292 posts
  • Corona SDK

I am wondering the same thing



[TOPIC: post.html]
#3

gtt

[GLOBAL: userInfoPane.html]
gtt
  • Contributor

  • 164 posts
  • Corona SDK

We're also started working with spine. And it's just awesome..

 

I've looked in the corona runtime and the creation of images is done via display.newImage and not display.newImageRect, so the answer to you question is that it aint supported yet...

 

 

We do plan to use @2x images by changing the call to display.newImageRect, and in spine just work with the x1 images.

 

Once you do that just have the @2x images ready for corona in the same directory and it should work just fine.

 

In the final product I would go even one step further and just twick the runtime to work with a spritesheet and pack all the images in it.

 

Hope this helps..



[TOPIC: post.html]
#4

cublah

[GLOBAL: userInfoPane.html]
cublah
  • Contributor

  • 393 posts
  • Corona SDK

We're also started working with spine. And it's just awesome..

 

I've looked in the corona runtime and the creation of images is done via display.newImage and not display.newImageRect, so the answer to you question is that it aint supported yet...

 

 

We do plan to use @2x images by changing the call to display.newImageRect, and in spine just work with the x1 images.

 

Once you do that just have the @2x images ready for corona in the same directory and it should work just fine.

 

In the final product I would go even one step further and just twick the runtime to work with a spritesheet and pack all the images in it.

 

Hope this helps..

 

It's not that it's not supported, it's that it's up to you to change display.newImage to display.newImageRect, as you said. We have had it working for the last month and it works fine, we have spine working with sprite sheets in hi and low res just by changing that function which is supposed to be changed to account for how you want to load the graphics.



[TOPIC: post.html]
#5

gtt

[GLOBAL: userInfoPane.html]
gtt
  • Contributor

  • 164 posts
  • Corona SDK

Sorry, that's actually what I meant.. I wrote "unsupported" because it is not in the public runtime release.. It's true you can modify the code as you wish and we did it on some other places as well but if the publisher of spine releases an update to the runtime obviously you'll need to adjust it again..



[TOPIC: post.html]
#6

startappsblog

[GLOBAL: userInfoPane.html]
startappsblog
  • Observer

  • 2 posts
  • Corona SDK

Great conversation, exactly what I was wanting to know. I'm at a cross roads of going SpriteSheet vs Spine.. and if @2x graphics wasn't do-able in Spine it was a deal breaker. Interestingly it appears that over 2 years on from this post, the spine Corona runtime still uses display.newImage() rather than display.newImageRect() at line 84 of https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-corona/spine-corona/spine.lua

 

Not sure if this works, but is the only fix the following (I have yet to actually purchase Spine)-  

--Was this.... 
-- Customizes where images are found.
function self:createImage (attachment)
       return display.newImage(attachment.name .. ".png")
end

--To This ?....
function self:createImage (attachment)
       return display.newImageRect(attachment.name .. ".png",attachment.width, attachment.height)
end



Cheers in advance!



[TOPIC: post.html]
#7

kilopop

[GLOBAL: userInfoPane.html]
kilopop
  • Contributor

  • 258 posts
  • Corona SDK

Try this when creating your spine objects in the skeleton:createImage function:

local imageSuffix 	= display.imageSuffix

function skeleton:createImage (attachment) -- called by spine.lua (function self:createImage (attachment))
		
	if imageSuffix ~= nil then -- does = @2 
		return display.newImage("spineData/"..dir..attachment.name .."@2.png")
	else
		return display.newImage("spineData/"..dir..attachment.name ..".png")
	end

end

Use your own directory there instead of the example provided ("spineData/"..dir..attachment.name .."@2.png").



[TOPIC: post.html]
#8

startappsblog

[GLOBAL: userInfoPane.html]
startappsblog
  • Observer

  • 2 posts
  • Corona SDK

Thanks kilopop, I will try out that modification! Cheers




[topic_controls]
[/topic_controls]