Hey guys,
So I'm trying to port a demo game over to Android to test out if it's working and I keep getting an error I don't get on the PC.
Somewhere between v9 and v11 image:refresh was replaced with image:replacePixels and I use it in a splash screen to make an image change. It works on the PC version of Love 11.3, but the Android APK 11.3 version throws an error:
splash.lua:28: attempt to call method 'replacePixels' (a nil value)
Now the APK file I'm using has been compiled and signed according to the Love Wiki and seems to at least load before crashing with this error. Also I know the images are included because before I compile to APK I tested the .love and it worked fine. Do any Android developers know why this might be the case? Or anyone?
[SOLVED] Love 11.3 replacePixels on Android not working?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] Love 11.3 replacePixels on Android not working?
Last edited by 4KbShort on Sun Jul 05, 2020 3:36 am, edited 1 time in total.
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Love 11.3 replacePixels on Android not working?
what's your actual code where you call replacePixels? Seeing that might help in identifying the issue.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Love 11.3 replacePixels on Android not working?
It sounds like either the version of love you're running on Android is older than 11.0, or you're calling replacePixels on the wrong object.
Re: Love 11.3 replacePixels on Android not working?
Here's the full code of the splash screen. It runs independently of the rest of the demo. I've also attached the zipped .love so you can run it if you want. It's a horrible mess and just tests features I was looking into, but it works. XD
Oh and for those who don't trace it I use a shortcut.lua file that points things like "love.graphics" to just "lg" and so forth so those aren't typos, promise!
Edit: Forgot to add that the version of LOVE for Android is the one from here:
https://github.com/love2d/love/releases ... -embed.apk
Which is the one the WIKI points to for APK compiling.
Oh and for those who don't trace it I use a shortcut.lua file that points things like "love.graphics" to just "lg" and so forth so those aren't typos, promise!
Edit: Forgot to add that the version of LOVE for Android is the one from here:
https://github.com/love2d/love/releases ... -embed.apk
Which is the one the WIKI points to for APK compiling.
Code: Select all
--! Update and draw the splash/logo screen with this file
local splash = {}
local logoTime = 10
local logoData = li.newImageData("imgs/logo/somewarelogo.png")
local logoDataB = li.newImageData("imgs/logo/somewarelogob.png")
local logo = lg.newImage(logoData)
local logob = lg.newImage(logoDataB)
local logoWidth = logo:getWidth()
local logoHeight = logo:getHeight()
local waitTime = 1
local currentPixelX = 0
--local theme = la.play("audio/music/Splash.wav","stream",false,"music")
function splash:updateSplash()
dt = lt.getDelta( )
if logoTime > 0 then logoTime = logoTime - dt end
if logoTime <= 0 or pressedKey ~= "" then la.stop(theme) logoTime = 0 activeScene = 1 pressedKey = "" end
end
function swapPixels()
if currentPixelX < 260 then currentPixelX = currentPixelX + 2 end
logoDataB:paste(logoData,currentPixelX,0,currentPixelX,0,1,logoHeight)
logoDataB:paste(logoData,currentPixelX -1,0,currentPixelX-1,0,1,logoHeight)
logob:replacePixels(logoDataB)
end
function splash:drawSplash()
swapPixels()
--Maybe do something fun with the little * dude cuz reasons.
lg.setColor(85,255,255)
lg.print("*", currentPixelX+20, 65)
lg.setColor(255,255,255)
lg.draw(logob, (windowWidth /2) - (logoWidth /2), (windowHeight /2) - (logoHeight /2))
end
return splash
- Attachments
-
- core.love
- (157.27 KiB) Downloaded 204 times
Re: Love 11.3 replacePixels on Android not working?
If you comment out the replacePixels line and add this to the end of splash:drawSplash(), what do you get?
It should be Version=11, luatype=userdata, lovetype=Image
Code: Select all
lg.print(("Version=%d, luatype=%s, lovetype=%s"):format(love.__version_major, type(logob),
type(logob)=="userdata" and logob:type() or "?"))
Re: Love 11.3 replacePixels on Android not working?
@pgimeno So I did what you asked and fun fact: the APK no longer installs. :/ Recompiled it about four times and it keeps getting an error. Did a little investigating and it seems I may have bumped into an old vs new issue.
So the other shoe is this: I'm trying to load this up on an OUYA, for... reasons and old versions of LOVE2D work fine, but the newest release of the Love2D for Android and, now apparently any versions of APKs compiled with the new version fail. This is probably due to an Android 4.1 vs 4.2 issue as I've discovered. If Love2D has moved to the Android 4.2 framework then that's that and without modding my Ouya I'm stuck which I think is the issue here. So while I can get a game that crashes on startup to load or even a game on Love 10 or 9 to work anything on 11+ is going to fail outright.
For now I have to table the Love2D side of the problem until I can get the OUYA side figured out.
Thanks again for all the assistance and I'll try to update this when I get somewhere.
So the other shoe is this: I'm trying to load this up on an OUYA, for... reasons and old versions of LOVE2D work fine, but the newest release of the Love2D for Android and, now apparently any versions of APKs compiled with the new version fail. This is probably due to an Android 4.1 vs 4.2 issue as I've discovered. If Love2D has moved to the Android 4.2 framework then that's that and without modding my Ouya I'm stuck which I think is the issue here. So while I can get a game that crashes on startup to load or even a game on Love 10 or 9 to work anything on 11+ is going to fail outright.
For now I have to table the Love2D side of the problem until I can get the OUYA side figured out.
Thanks again for all the assistance and I'll try to update this when I get somewhere.
Re: Love 11.3 replacePixels on Android not working?
So I went through a bunch of stuff and ended up installing Lineage OS (CM11) on my Ouya which put it at Android 4.4.4 apparently. Tried my APK packed love games that way and they're still failing one way or the other. Either replacepixel fails, the APK fails to install, or if the game is super simple it runs fine. All things happening on the native Ouya OS. So I have to assume the problem is with my code and not what I'm trying to run it on.
Re: Love 11.3 replacePixels on Android not working?
Yes, I did.
I figured out the best solution was to stick with Love 10.3. Image:refresh works fine, but replacepixel in 11 does not. No idea why.
Since I'll never use anything 11 offers for a simple game I'm not too concerned. I consider this solved, even though the solution was to back down a few version.
Thanks again for all the help!
I figured out the best solution was to stick with Love 10.3. Image:refresh works fine, but replacepixel in 11 does not. No idea why.
Since I'll never use anything 11 offers for a simple game I'm not too concerned. I consider this solved, even though the solution was to back down a few version.
Thanks again for all the help!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 11 guests