2017년 1월 8일 일요일

imagesprite


How to create an event for when any image sprite is touched.We have an option "when image sprite touched" for only one imagesprite.How do i create some event that occurs if ANY of the image sprite is touched.

--
The simplest way is to have a Touched event block for every ImageSprite.

A more complicated approach might be to track in a list where each imagesprite is located (it's X and Y values.)
Then, using the Canvas Touched event block and it's touchedAnySprite variable, if the value of touchedAnySprite is true, then determine which sprite was touched by comparing the x and y values of Canvas Touched to the x and y values stored in the list.
This is made more complicated by the fact that imagesprites might overlap!

Another approach is to use image mapping in that when an image on the canvas is touched, compare the x,y of the touch to minimum x,y and maximum x,y values for a rectangular area on the background image.
If it is within the specified range, then that 'button' or area was touched.

The minimum and maximum values would be stored in a list of lists or up to four lists.

-- 

댓글 없음:

댓글 쓰기