Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Marching ants configurability
Started by danielr0 Apr 10 2016 10:05 PM

3 replies to this topic

Best Answer Brent Sorrentino , 11 April 2016 - 12:25 PM

Hi @danielr0,

As you can see in our guide, there are some configuration options for marching ants:

 

https://docs.coronalabs.com/daily/guide/graphics/effects.html#generator.marchingants

 

However, it may not be enough to accomplish every detail you describe. In that case, you may be able to "fill" a stroke (outline) around the object with a bitmap image, or use frames from an image sheet... so yes, basically you're on the right track with thinking that a repeating image fill could accomplish exactly what you need.

 

Take care,

Brent

[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

danielr0

[GLOBAL: userInfoPane.html]
danielr0
  • Enthusiast

  • 44 posts
  • Corona SDK

I was wondering how configurable the object.stroke.effect = "generator.marchingAnts" are?

 

I want to draw a simple dotted/dashed line.

I need to have static ants instead of them moving.

I need to be able to change the line colour from black+white to color+transparent.

I need to be able to change the width and distance between dots/dashes.

 

I guess I have to do this with a repeating image or something.



[TOPIC: post.html]
#2

Brent Sorrentino

[GLOBAL: userInfoPane.html]
Brent Sorrentino
  • Moderator

  • 7,950 posts
  • Corona Staff

  Best Answer

Hi @danielr0,

As you can see in our guide, there are some configuration options for marching ants:

 

https://docs.coronalabs.com/daily/guide/graphics/effects.html#generator.marchingants

 

However, it may not be enough to accomplish every detail you describe. In that case, you may be able to "fill" a stroke (outline) around the object with a bitmap image, or use frames from an image sheet... so yes, basically you're on the right track with thinking that a repeating image fill could accomplish exactly what you need.

 

Take care,

Brent



[TOPIC: post.html]
#3

danielr0

[GLOBAL: userInfoPane.html]
danielr0
  • Enthusiast

  • 44 posts
  • Corona SDK

Thanks.

 

For other people: My solution

Make a 1x2 pixel image of a white and transparent pixel side-by-side.

Use the following code to draw it.

display.setDefault( "textureWrapX", "repeat" )
local dash = display.newRect(xPos, yPos, rectWidth, 1) --I suppose you could rotate it after making it to have more than just a horizontal dashed line
dash.fill = {type='image', filename='dash.png'} --must be png(or not jpg) to support transparency
dash.fill.scaleX = imagePixelWidth / rectWidth --this preserves pixel size. you can resize it how you want. you need to know pixel width beforehand or find it somehow.
dash:setFillColor(0.5,0.5,0.5) --set to whatever color you want. for tables of colors, remember to use unpack(table)


[TOPIC: post.html]
#4

ouguolin

[GLOBAL: userInfoPane.html]
ouguolin
  • Observer

  • 17 posts
  • Corona SDK

thanks danielr, your solution is what I want. :)




[topic_controls]
[/topic_controls]