Guys could you see if you could help? I have made another group, so now I’m trying to move the group. The code is listed down below, but the problem is, it’s not moving all the objects in the group. Why not?
[lua]module(…, package.seeall)
_W = display.contentWidth;
_H = display.contentHeight;
require “sprite”
require “ui”
function new()
local localGroup = display.newGroup();
local localGroup2 = display.newGroup()
sky = display.newImage(“sky.jpg”)
sky.x = _W/2; sky.y = _H/2;
local button1 = ui.newButton{
default = “stupidpigbutton.png”,
–over = “playbuttonin.png”,
onRelease = tmr1,
}
button1.x = _W/4.5; button1.y = _H/2
button1.xScale = 1; button1.yScale = 1
button1.scene = “pigselect”
local button2 = ui.newButton{
default = “flyingpigbutton.png”,
–over = “playbuttonin.png”,
onRelease = tmr1,
}
button2.x = _W/1.5; button2.y = _H/2
button2.xScale = 1; button2.yScale = 1
button2.scene = “pigselect”
local button3 = ui.newButton{
default = “ninjapigbutton.png”,
–over = “playbuttonin.png”,
onRelease = tmr1,
}
button3.x = _W/1 + 55; button3.y = _H/2
button3.xScale = 1; button3.yScale = 1
button3.scene = “pigselect”
local button4 = ui.newButton{
default = “selectpigbutton.png”,
over = “selectpigbuttonin.png”,
onRelease = changeScene,
}
button4.x = _W/1.9; button4.y = _H/1.1
button4.xScale = 1; button4.yScale = 1
button4.scene = “game”
pig = display.newImage(“annoyingpig.png”)
pig.x = _W/4.8; pig.y = _H/1.9
pig.xScale = .35; pig.yScale = .35;
localGroup2:insert(button1)
localGroup2:insert(button2)
localGroup2:insert(button3)
local pig1anim = function (event)
transition.to( pig, { time=200, xScale = .5, yScale = .5 } )
transition.to( pig, { time=200, delay = 200, xScale = .4, yScale = .4 } )
end
local function onTouch( event )
local t = event.target
local phase = event.phase
if “began” == phase then
local parent = t.parent
parent:insert( t )
display.getCurrentStage():setFocus( t )
t.isFocus = true
t.x0 = event.x - t.x
elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end
return true
end
local function tmr1(e)
local tmr1 = timer.performWithDelay(400, pig1anim, 0 )
end
localGroup:insert(sky)
localGroup:insert(button4)
localGroup:insert(pig)
localGroup.x = _W/1 - 200
transition.to( localGroup, { timer = 2500, y = 0, x = _W/6 - 70} )
function changeScene(e)
if(e.phase == “ended”) then
director:changeScene(e.target.scene, “crossfade”);
end
end
localGroup2:addEventListener(“touch”, onTouch)
button1:addEventListener(“tap”, tmr1)
button4:addEventListener(“touch”, changeScene)
return localGroup
end[/lua]
Thanks for all your help.
Regards,
Jordan Schuetz
Ninja Pig Studios [import]uid: 29181 topic_id: 13201 reply_id: 48713[/import]