2017년 8월 12일 토요일

overlapping of image sprites


 i am working on an app which has many image sprites ,but the problem is that the image sprites are overlapping,so can anyone please help in this issue to avoid image sprite overlapping

--
If you are having trouble dragging them without them sticking together,
look for "sprite cannibalism" in this board's search bar.

The sprite attributes in the Designer let you restrict their active areas.

Also be aware of the sprite image sizes in pixels, and
don't let them get too big.

--
Also, remember the difference between images of sprites and the sprites themselves.

Depending on your app, you can switch images in a Sprite at run time
as needed, having many more image files in the Media Drawer than actual Sprites.

--
Sir actually my app consists of 3 image sprites and I have assigned their x and y coordinates such that it is generated using random module in math available in app inventor 2 ,can you suggest any other solution as I am not dragging the images ....

--
You would have to write a procedure ("overlaps") that accepts two Sprites and
returns true if they overlap, and reject new sprites that overlap
already chosen sprites.  (Keep  a list of them.)

Use the Any Sprite blocks to get at the x,y,width, and height attributes
of each sprite.  You will need them to determine the 4 boundaries of each sprite.

Since each sprite is a rectangle, that means two sprites overlap if
and only if their x domains overlap and their y domains overlap.

That requires a bunch of nested comparisons of the end points,
low to high, of each edge, in each dimension.

See this link for a slightly different problem, where a procedure has
to decide if a sprite has its center inside another sprite ... Drag and Swap Puzzles in JSON

I don't have anything lying around for the overlaps problem.

--
Attached is another project I had lying around, where the problem
was to add new random circles to a canvas without overlapping the
old circles.

This one used no sprites, just lists of where the circles were and their radii.

The overlap calculation is different, based on diagonal distance versus radii.

But the management of the items is similar.







































--

댓글 없음:

댓글 쓰기