Home / Topic / Sprite Sheet problems

Sprite Sheet problems

Viewing 8 posts - 1 through 8 (of 8 total)
  • #9490

    I find it unbelievable that I can't for the life of me get a sprite sheet to work.I have watched the Kwik youtube tutorial 4 times, I have followed every step, I have tried referencing the sprite sheet within the Build folder and outside the build folder.  I have tried everything.WHAT is the problem?  The really odd thing is that once I did get it to work, but that's just 1 time out of 19 tries.Also, is it really required to have the sprite sheet dimensions?  I noticed that on earlier versions of Kwik in the youtube video they only use the dimensions of the replacement.Here's the Lua file for the failed simple sprite sheet test.Thanks!-- Book created by Kwik for Adobe Photoshop  - Developed by Kwiksher -- Copyright (C) 2012 kwiksher.com. All Rights Reserved. -- uses Director class, by Ricardo Rauber -- uses DMC classes, by David McCuskey -- Exported on Thu Sep 20 2012 14:39:37 GMT-0700 _G.kwk_readMe = 0 local director = require("director") Gesture = require("dmc_gesture") MultiTouch = require("dmc_multitouch") system.activate("multitouch") require("sprite") display.setStatusBar( display.HiddenStatusBar ) imgDir = "images/" audioDir = "audio/" _G.lang = "" _G.kBidi = false _G.kAutoPlay = 0 local initPage = 1 local goPage = 1 --Bookmark function local path = system.pathForFile( "book.txt", system.DocumentsDirectory ) local file = io.open( path, "r" ) if file then   goPage = file:read("*l")   _G.kBookmark = file:read("*l")   if _G.kBookmark == 1 then initPage = goPage end   io.close(file) else   local path = system.pathForFile( "book.txt", system.DocumentsDirectory )   local file = io.open( path, "w+b" )   file:write ( "1n0" )   _G.kBookmark = 0   io.close(file) end -- Create a main grouplocal mainGroup = display.newGroup()-- Main functionlocal function main() -- Add the group from director class mainGroup:insert(director.directorView) director:changeScene( "page_"..initPage ) return trueend--Clear timers and transitionstimerStash = {}transitionStash = {}gtStash = {}function cancelAllTimers()    local k, v    for k,v in pairs(timerStash) do        timer.cancel( v )        v = nil; k = nil    end    timerStash = nil    timerStash = {}end--function cancelAllTransitions()    local k, v    for k,v in pairs(transitionStash) do        transition.cancel( v )        v = nil; k = nil    end    transitionStash = nil    transitionStash = {}end--cancel all gtweensfunction cancelAllTweens()    local k, v    for k,v in pairs(gtStash) do        v:pause();        v = nil; k = nil    end    gtStash = nil    gtStash = {}end-- Beginmain()

    Anonymous
    Inactive
    #12852

    J., the code you pasted is not related to the sprite sheet usage (code for that is in a page_x.lua, not in the main.lua file). Send me your project folder and I will check for you. You may have a bad sheet, a bad config, a sheet file larger than 2048×2048 (maximum accepted),…

    mirta_boyce
    Participant
    #12853

    I am in the same boat! I have spent 3 days trying to get a sprite to load properly and work. I watched all the demos, re-read the instructions over and over again. Very frustrating! This needs to be a lot easier rather than replacing…like name the layers_sprite. Here is my 1 page code…all assets are in the build folder properly.-- Code created by Kwik - Copyright: kwiksher.com -- Version: 2.0.1 module(..., package.seeall) function new()     local numPages = 1     local menuGroup = display.newGroup()     local dispose     local _W = 960     local _H = 640     local drawScreen = function()       -- (TOP) External code will render here       local curPage = 1       if (_G.kBookmark == 1) then           local path = system.pathForFile( "book.txt", system.DocumentsDirectory )           local file = io.open( path, "w+" )           file:write ( curPage.."n1" )           io.close( file )       end         if (_G.kAutoPlay > 0) then           local function act_autoPlay (event)             if(curPage < numPages) then                 if(_G.kBidi == false) then                    dispose(); director:changeScene( "page_"..curPage+1, "moveFromRight" )                 else                    dispose(); director:changeScene( "page_"..curPage-1, "moveFromLeft" )                 end              end           end           timerStash.timer_AP = timer.performWithDelay( _G.kAutoPlay*1000, act_autoPlay, 1 )       end         local background        local swishfish        -- background positioning       background = display.newImageRect( imgDir.. "p1_background.png", 960, 640 );       background.x = 480; background.y = 320; background.alpha = 1; background.oldAlpha = 1       menuGroup:insert(background); menuGroup.background = background       -- swishfish positioning       swishfish_options = { width = 23, height = 13, numFrames = 2, sheetContentWidth = 480, sheetContentHeight = 320 };       swishfish_sheet = graphics.newImageSheet( imgDir.. "fish2.png", swishfish_options )       swishfish_seq = { name = "and1348", start = 1, count = 2, time = 1000, loopCount = 0, loopDirection = "forward" };       swishfish = display.newSprite(swishfish_sheet, swishfish_seq )       swishfish:play();       swishfish.x = 400; swishfish.y = 526; swishfish.alpha = 1; swishfish.oldAlpha = 1       menuGroup:insert(swishfish); menuGroup.swishfish = swishfish       -- Group(s) creation       -- (MIDDLE) External code will render here       -- swipe this page with spacer of 120 in normal direction       Gesture.activate( background, {swipeLength=120} )       local function pageSwap (event )         if event.phase == "ended" and event.direction ~= nil then              local wPage = curPage              local direction              if event.direction == "left" and _G.kBidi == false then                wPage = curPage + 1                if wPage > numPages then wPage = curPage end                direction = "moveFromRight"              elseif event.direction == "left" and _G.kBidi == true then                wPage = curPage - 1                if wPage < 1 then wPage = 1 end                direction = "moveFromLeft"              elseif event.direction == "right" and _G.kBidi == true then                wPage = curPage + 1                if wPage > numPages then wPage = curPage end                direction = "moveFromRight"              elseif event.direction == "right" and _G.kBidi == false then                wPage = curPage - 1                if wPage < 1 then wPage = 1 end                direction = "moveFromLeft"              end              if wPage ~= curPage then dispose();               dispose(); director:changeScene("page_"..wPage, direction)             end         end        end       background:addEventListener( Gesture.SWIPE_EVENT, pageSwap )       function cleanSprite()                           swishfish_sheet = nil       end       -- (BOTTOM) External code will render here     end     drawScreen()       function clean()           cleanSprite()       end     dispose = function (event)       cancelAllTimers()     end     return menuGroup end

    Anonymous
    Inactive
    #12854

    Guys, I will write a new tutorial on sprite sheet replacements (it seems there is still some confusion here :). Meanwhile:- check the Learn Kwik 2 pages for better understand on how the feature works;- DO NOT paste code here in the forums. It is very hard to say what is wrong just with the code. For example, Coolhand71 code seems to be right, which leaves me to believe the issue is on the sheet file or in the info passed to Kwik. In cases like this, send you project for analysis via support@kwiksher.com

    mirta_boyce
    Participant
    #12855

    Thanks Alex.I have been through the online document quite a bit. Everything seems to process OK, it just that when it is previewed in the the Corona Simulator it is either zoomed in or not present. In your tutorial, if you could let us know if any changes need to be made to the sheet size and...I also noticed that when a sheet is created in the export, the dimensions change. For example, I might have a sprite created in PS and the dimensions are 45px by 45px. Upon export, the dimensions are 45px by 48px. Which dimensions should we use...the original or the exported upon replacement?Thanks for your efforts and responsiveness!

    Anonymous
    Inactive
    #12856

    New tutorial on sprite sheet is available at http://www.kwiksher.com/learn-kwik2/tutorial-sprites/ take a look!

    gretaltreloarnclbi
    Participant
    #12857

    in the new tutorial many different graphics are packed in the same sprite sheet. I hadn't thought of using a sprite sheet like that. So each frame is used on its own and then animated with kwik's animation features.. Lets say you want to use the sprite sheet in the example for many different pages, when you build will it export the same frame from the sheet for each page or is the sprite sheet only exported once and many pages get to use it ? that would save a lot of memory

    Anonymous
    Inactive
    #12858

    The example was just to make really visible what you can do with sprite sheets. at this moment thou Kwik cannot work with sprite sheet sequences.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.