Could anyone please help me with the code to set up a sprite so it's draggable on screen? I've been over and over the documentation but getting nowhere.
--
Sprite visibility is currently broken i.e. your sprite wont show up...
--
If you set specific pixel dimensions, the sprite does show up. I can
even get something to fire with code when mySprite.Dragged (I change bg color) but the dragging doesn't happen.
even get something to fire with code when mySprite.Dragged (I change bg color) but the dragging doesn't happen.
--
The dragged block of an image sprite component doesn't actually update the image sprite x and y coordinates. It only *reports* the position in which your finger is dragging along the screen. Therefore, you need to update the coordinates manually. Fortunately that is easy to do. In your block, just put in MoveTo block and in the x and y parameters, just pass the currentX and currentY variables that is being passed to the event block.
--
Now moving it us easy, but you may notice that it is being dragged by the top left corner of the sprite. Thus is due to the fact that the x and y properties of the sprite refers to that position.
Now moving it us easy, but you may notice that it is being dragged by the top left corner of the sprite. Thus is due to the fact that the x and y properties of the sprite refers to that position.
To resolve this you just need some math.
call ImageSprite1.MoveTo
X => [ currentX - [ ImageSprite1.Width / 2 ] ]
Y => [ currentY - [ ImageSprite1.Height / 2 ] ]
X => [ currentX - [ ImageSprite1.Width / 2 ] ]
Y => [ currentY - [ ImageSprite1.Height / 2 ] ]
--
Thanks so much. I got it working on two tiny sprites, probably a little overcoded but I'm very excited to have made this step forward.
Thanks so much. I got it working on two tiny sprites, probably a little overcoded but I'm very excited to have made this step forward.
I disabled one sprite to move the other. The move is a little jerky
but is a drag and drop, so pleased, will continue playing with this
tomorrow.
--
but is a drag and drop, so pleased, will continue playing with this
tomorrow.
--
Cool. **Does the Jason's Happy Dance** =)
Hope to see some good stuff from this. Performance with AI in regards to Sprite animation isn't all that good, but there is a method (or a way of coding) that can help it improved a bit. I'll let you play
around with what you have for now and if you think you need some
performance enhancement, I can try teaching you what I know. Warning:
it's not pretty and its a fairly complex technique.
Hope to see some good stuff from this. Performance with AI in regards to Sprite animation isn't all that good, but there is a method (or a way of coding) that can help it improved a bit. I'll let you play
around with what you have for now and if you think you need some
performance enhancement, I can try teaching you what I know. Warning:
it's not pretty and its a fairly complex technique.
--
*joins "Tha Dance"* its not mine. "THA Dance" belongs to all men and women.
--
--
I can now drag my blocks - thanks! I've made your equations to allow the sprite to be dragged from its centre with blocks (see picture) but I can't get them to stick to the MoveTo block (it says ' This block cannot plug into this socket because >= is a boolean and can't be a number'). How do I do this please?
--
there was a misunderstanding... there is no >= involved ... hth ...
ImageSprite1.MoveTo (currentX - [ ImageSprite1.Width / 2 ]
currentY - [ ImageSprite1.Height / 2 ]
)
--
ImageSprite1.MoveTo (currentX - [ ImageSprite1.Width / 2 ]
currentY - [ ImageSprite1.Height / 2 ]
)
--
Remove the >= block and plug the rest into a move to block
--
댓글 없음:
댓글 쓰기