I’ve just finished my app for kids which incorporates flashcards, letters and numbers.
I’m using a sliderGroup to hold all the individual slides. Everything works fine in the simulator and on the iPhone (iOS 5), but the alphabet flashcard slides won’t work on the iPad (iOS 4.3.5) It crashes when loading the scene. The strange thing is, having tested loads of combinations, it will work with only 24 of the 26 slides. It doesn’t matter which two I take out, as long as there’s a maximum of 24 slides.
Is there any way to increase the amount of slides I can display? Or is this a problem with iOS 4?
Sample of the code: I’ve only put in the first two slides and the associated audio files.
[code]
module(…, package.seeall) --ACTIVATE THIS LINE IF USING DIRECTOR; REMOVE IF NOT
local math_abs = math.abs
local cw, ch, ox, oy = display.contentWidth, display.contentHeight, math_abs(display.screenOriginX), math_abs(display.screenOriginY)
–“ox” and “oy” calculate the X/Y ‘offset’ at different screen proportions, i.e. iPhone vs. Galaxy Tab vs. iPad
–Setup Display Groups
local localGroup = display.newGroup()
local GUI = display.newGroup()
local sliderGroup = display.newGroup()
local slideDist = cw+ox+ox --total left-to-right distance of a slide
local slideIndex = 0
local touchPos = 0
local lastPos = 0
local touchTime = 0
–A ‘swipe’ is basically just a SHORT (distance) and FAST (time) screen touch. The variable “coreSwipeDist” sets the DISTANCE aspect
–of a swipe. Default in this module is 1/10th the screen width. Adjust if you desire a longer or shorter distance to register as a ‘swipe’
–The variable “coreSwipeTime” is the TIME aspect (in milliseconds) which registers as a swipe. If the user’s touch is longer than this value,
–this module considers that motion a DRAG/HOLD, not a swipe. Adjust this time value to your desire.
–NOTE!!! After you determine the values that feel right to you, I suggest you replace these variables below (in function “screenMotion”)
–with the hard-coded values, so Corona doesn’t need to waste effort on upvalue lookups.
local coreSwipeDist = cw/10
local coreSwipeTime = 300
local slideTrans = 0 --the tween transition variable; when set to 0, transition is not happening.
local maxSlideIndex = 0 --max number of slides, to be automatically set later.
local resist = 1
local function transComplete( event )
transition.cancel( slideTrans ) ; slideTrans = 0
local targetX = (slideIndex*-slideDist) ; if ( sliderGroup.x ~= targetX ) then sliderGroup.x = targetX end
end
– Sounds for flashcards
local function letASound(event)
audio.play( apple1 )
end
local function letBSound(event)
audio.play( ball1)
end
–Transition to next slide
local function slideTween( targetX )
–Overall transition time is 400 milliseconds by default. Adjust if you desire slower or faster slide movement.
local transTime = ( (math_abs(sliderGroup.x-targetX))/slideDist) * 400
if ( slideTrans ~= 0 ) then transition.cancel( slideTrans ) ; slideTrans = 0 end
slideTrans = transition.to( sliderGroup, { x=targetX, time=transTime, transition = easing.outQuad, onComplete=transComplete } )
end
local function gotoSlide( targetSlide, method )
if ( slideTrans ~= 0 ) then transition.cancel( slideTrans ) ; slideTrans = 0 end
local si = targetSlide-1 ; slideIndex = si ; local destX = (si*-slideDist)
if ( method == “snap” ) then sliderGroup.x = destX ; updateDots( si )
else slideTween( destX )
end
end
–Core touch sensor + movement/swipe function
local function screenMotion( event )
local phase = event.phase ; local eventX = event.x
if ( “began” == phase ) then
if ( slideTrans ~= 0 ) then transition.cancel( slideTrans ) ; slideTrans = 0 end
touchPos = eventX ; lastPos = eventX ; touchTime = event.time
elseif ( “moved” == phase ) then
local dist = eventX-lastPos ; local res = resist
–“resist” is the ratio (percentage) for the end-of-stack spring resistance effect. At either end of your stack of slides, if the
–user tries to slide further, this module “resists” that movement to indicate that there are no more slides, just like iOS! 
–Default is “0.3” on line 126 ; you may change this, but 0.5 or higher risks the ability to move the slide off the screen!
if ( ( slideIndex == 0 and dist > 0 ) or ( slideIndex == maxSlideIndex and dist < 0 ) ) then res = 0.3 else res = 1 end
sliderGroup.x = sliderGroup.x+(dist*res) ; lastPos = eventX ; resist = res
else
local motionTime = system.getTimer()-touchTime
local dist = eventX-touchPos ; local swipeDist = math_abs( dist )
local overallDist = math_abs( sliderGroup.x+(slideIndex*slideDist) )
local goNextSlide = false
if ( resist ~= 1 ) then goNextSlide = false
elseif ( motionTime <= coreSwipeTime and swipeDist >= coreSwipeDist ) then goNextSlide = true
elseif ( motionTime > coreSwipeTime and overallDist >= slideDist*0.5 ) then goNextSlide = true end
if ( goNextSlide == true and dist < 0 and resist == 1 ) then slideIndex = slideIndex+1
elseif ( goNextSlide == true and dist > 0 and resist == 1 ) then slideIndex = slideIndex-1 end
slideTween( slideIndex*-slideDist )
end
end
local function initSetup()
local letAGroup
–create 4 sample slides using a loop:
letAGroup = display.newGroup() --IMPORTANT!!! Create a new display group for each slide!
localGroup:insert(letAGroup) --ACTIVATE THIS LINE IF USING DIRECTOR
– slide background (image or just a simple rect in this example)
local flashA = display.newImageRect( “images/Flashcards/apple.jpg”, 320,480)
flashA:setReferencePoint(display.centerReferencePoint)
flashA.x=cw/2; flashA.y=ch/2
letAGroup:insert( flashA )
sliderGroup:insert( letAGroup )
letAGroup.x = ((sliderGroup.numChildren-1)*slideDist)
local letBGroup
–create 4 sample slides using a loop:
letBGroup = display.newGroup() --IMPORTANT!!! Create a new display group for each slide!
localGroup:insert(letBGroup) --ACTIVATE THIS LINE IF USING DIRECTOR
– slide background (image or just a simple rect in this example)
local flashB = display.newImageRect( “images/Flashcards/ball.jpg”, 320,480)
flashB:setReferencePoint(display.centerReferencePoint)
flashB.x=cw/2; flashB.y=ch/2
letBGroup:insert( flashB )
sliderGroup:insert( letBGroup )
letBGroup.x = ((sliderGroup.numChildren-1)*slideDist)
maxSlideIndex = sliderGroup.numChildren-1
sliderGroup:addEventListener( “touch”, screenMotion )
letAGroup:addEventListener( “tap”, letASound )
letBGroup:addEventListener( “tap”, letBSound )
end
initSetup()
function new()
return localGroup
end
[/code] [import]uid: 92074 topic_id: 17362 reply_id: 317362[/import]