Please Help Spawn Images And Move to a specify x.y

This is driving me crazy its been a couple of days and when Im close to accomplishing this something else screws it up. What im trying
to accomplish is pretty straightforward:

1: Spawn Images on random location
2: When images spawn they should make their way to center of screen.
3: If you touch image you can drag them like [Multi Puck Sample]

Please help and if you can post a sample code or snippet Id be very grateful! The Reason I dont post my code Is because I have try so many
different method it will be pointless, might be best explain all I tried.

I can make images spawn on different location (1)

I also manage to make images make their way to center of screen(2)
The problem is if I use transition.to then while they are on route It wont
let me drag the object using Multi Puck Dragging Code until the object
has finish its transition. I also tried using Beebegames Class obj:moveTowards()
and that will allow me to drag the object while is on route but the problem is
if I try to remove the object I get an error and its due to Beebegames.lua the
function that causes obj:moveTowards uses mCeil and if you remove the object
thats on route using obj:moveTowards() you will get an Error.

I can make the image draggable using Multi Puck sample [3] the only problem
as explained above if the object is doing a transition.to it wont allow me to drag
it.

So bottom line can anyone please land a hand on how this is accomplish ?
Or just point me in the right direction :frowning:

Thanks in advance !! [import]uid: 30314 topic_id: 17098 reply_id: 317098[/import]

Here’s a clue for you to resolve this

You know that you can cancel a transition half way.
cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17098 reply_id: 64271[/import]

JayantV, can you, please, tell me how to properly cancel transition?
thanks [import]uid: 16142 topic_id: 17098 reply_id: 64279[/import]

SPOILER ALERT!!

it is very simple,

 local trans  
  
...  
  
 trans = transition.to(object,{time=1000,x=100,y=100)  
  
...  
  
 transition.cancel(trans)  
  

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17098 reply_id: 64280[/import]

wow, i didnt even know of transition.cancel) thanks [import]uid: 16142 topic_id: 17098 reply_id: 64282[/import]

can i ask another silly question? is there any way to resume canceled transition?

i did it by this method, but its kinda ugly, isnt there an api for resuming?

[lua]local player = display.newCircle(0,0,50)
player.x = 150
player.y = 150

var = true

local function left()
trans = transition.to(player, {time=800, x = 100, onComplete = right})
end

local function right()
trans2 = transition.to(player, {time=800, x = 300, onComplete = left})
end

right()

local function can()
transition.cancel(trans2)
var = false
end

local function can2()
if var == false then
right()
end
end

timer.performWithDelay(300, can, 1)
timer.performWithDelay(2000, can2, 1)[/lua] [import]uid: 16142 topic_id: 17098 reply_id: 64318[/import]

Thanks for replies,

The problem with canceling a transition on my game is the following:
If the user touches the object and i cancel the transition to allow the
user to drag the object then if the user decides to NOT drag the object
and just touched the object since transition got cancel the object just
stays there, So in order to avoid this if used leaves object alone then I
start a new transition but it`s kinda ugly the results because if you
expect an object to spawn lets say on x = 0 and make it half screen
in 3 seconds the object will travel at a certain speed. If mid way you
cancel transition and start a new transition in it will take object 3 seconds
to make it from mid way to middle of screen instead of just taking the object
1.5 seconds since it always travel midway. I also tried using Transition Manager
to pause transition since we DONT have an API transition.pause() but Didnt get
the results I wanted ;(

Hence why I asked if anyone can please post a sample code or snipper on how
they will actually accomplish this :wink: Thanks! [import]uid: 30314 topic_id: 17098 reply_id: 64387[/import]

Hey @Darkconsoles (is that the PS3 or the new XBox 360), just want to bring your attention to one small minor thing.

–> transition.cancel
^^^^^^

so there is no way of resuming, however if we had something like Pause then we could resume.

I cannot recollect where, there is a tween kind of example that answers the problem of resuming transitions, the items is tweened based on the position it is in the transition based on the time.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17098 reply_id: 64390[/import]

For drag object I normally use the animation instead of image. Because animation already have setdrag parameter to control drag on/off.

For transition, sometime I use transition.to but there are another way to do transition. Please check out this link they call “Manual animation”. I saw some people’s sample posted here using this method to transit a object from x to y. (But sorry I’cant remember the sample name.)

http://developer.anscamobile.com/content/animation
for animation “setdrag”, please check out this link

http://developer.anscamobile.com/reference/index/objectsetdrag

Hope this help.

KC
Bonvivid
[import]uid: 94613 topic_id: 17098 reply_id: 65415[/import]

@ mycorona

Wow Thanks the object:setDrag looks promising it might actually get the
job done! lol [import]uid: 30314 topic_id: 17098 reply_id: 65416[/import]

just make a simple change on my code. Not sure this is you want.

KC
Bonvivid

_____________________________________________________

module(…, package.seeall)
function new()

local localGroup = display.newGroup()

local _H = display.contentHeight
local _W = display.contentWidth

local movieclip = require(“movieclip”)

local targets = {
“target1.png”,
“target2.png”,
“target3.png”,
“target4.png”,
“target5.png”,
“target6.png”
}

local myAnim4 = movieclip.newAnim{ targets[1], targets[2], targets[3], targets[4], targets[5], targets[6] }
myAnim4:play{ startFrame=1, endFrame=1, loop=1, remove=false }
myAnim4.x = _W/8*1
myAnim4.y = _H/8*1
myAnim4.xScale = 1
myAnim4.yScale = 1
myAnim4.count = 0;
localGroup:insert(myAnim4)

local function pressFunction()

transition.cancel(trans2)
myAnim4.alpha = 0.7
end

local function releaseFunction()
myAnim4.alpha = 1.0
end
myAnim4:setDrag{
drag=true,
onPress=pressFunction,
onRelease=releaseFunction,
}

trans2 = transition.to( myAnim4, { time=5000, x=_W/8*1, y = _H/8*7,} )

return localGroup

end
[import]uid: 94613 topic_id: 17098 reply_id: 65419[/import]